file sync on close(2)
file sync on close(2)
- Subject: file sync on close(2)
- From: "Jay A. Kreibich" <email@hidden>
- Date: Mon, 7 Jun 2004 23:56:07 -0500
I have a fairly simple question, but I need a very sure answer.
If close(2) is called on the last file descriptor that references
a standard file, are dirty pages associated with that file's buffers
automatically queued for writing, in a similar manor to sync(2)?
Everyone I've talked to has said "I think so," but I'm looking for
something a bit stronger.
The reason I ask is this: We've got an OS X box in a very remote
location that has pretty flaky power. We've got a UPS, but there are
times when even that isn't enough. The problem is if the UPS
software shuts down the machine, it will not restart once power comes
back. The *only* way to get it to restart is to press the power
button, and trust me-- given where this machine is, that's a serious
pain the butt. The same behavior is displayed with halt(8) and
any other number of commands I've tried.
So my thought is to modify the UPS scripts to "almost" shut the machine
down, and then just let the power fail. The "automatically restart on
power failure" should then catch the machine and allow it to come back
on its own.
Of course, the thought of just ripping the power out from under a
machine will give most admins the willies, so I was trying to come
up with a way to put the system in an absolute minimal state before
allowing the power to be cut. Sending init(1) a SIGTERM to dump the
system into single user mode seems like a good bet. That leaves the
system with nothing but init and a shell running, both of which will
sit there and do nothing.
In looking at how init(1) brings the system down, I noticed that it
does the standard "kill everything" sequence of SIGHUP, wait,
SIGTERM, wait, SIGKILL. It doesn't actually call sync(2), however,
which brings up the question: does it need to? If the processes are
allowed to exit or are killed, and their file descriptors are closed
out as the processes are cleaned up, are the dirty pages associated
with such files written out? Or do they just sit in memory waiting
for something to happen? I can't call sync(8) *after* we get into
single-user mode, since the transition will cause init to kill my
script.
So is this a safe plan, or do I need to worry about dirty pages?
-j
--
Jay A. Kreibich | Integration & Software Eng.
email@hidden | Campus IT & Edu. Svcs.
<
http://www.uiuc.edu/~jak> | University of Illinois at U/C
_______________________________________________
darwin-kernel mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/darwin-kernel
Do not post admin requests to the list. They will be ignored.