Editing inittab?

Dave Levenson dave at westmark.UUCP
Tue Apr 4 11:32:47 AEST 1989


I need to alter the list of daemons running under SysV/386 Rel 3.2,
but I believe the question is applicable to most UNIX versions:

When is it ever safe to edit /etc/inittab when UNIX is running?
The init(1) program reads this file whenever it is told to by
telinit or init Q.  It also reads this file whenever one of its
children dies.

If I'm editing the file, and have decided to re-write it just as
init decides to re-read it, there is an interval where the file does
not exist.  (The editor has unlinked the old file, and hasn't yet
linked the new file to the name.  -- Or worse, the editor has opened
the file for writing, and truncated it, and hasn't yet finished
writing the new contents.)  Init tries to read the inittab file,
finds that it doesn't exist, and kills off its remaining children. 
It logs me off (and any other users who happen to be there.  It
leaves the machine in single-user mode with a root shell on the
console.

Is there a way to hold off init long enough to re-write the inittab
after its contents have been changed?  Is there an atomic way of
relinking the file?  Can I lock the file?

If I cannot predict when some random daemon or logged-in user might
exit and wakeup init, how can I tell when it's safe to edit inittab?

-- 
Dave Levenson			/-----------------------------\
Westmark, Inc.			|  If you can't give me your  |
Warren, NJ USA			|  Phone number, don't call!  |
{rutgers | att}!westmark!dave	\-----------------------------/



More information about the Comp.unix.questions mailing list