Quote:
Originally Posted by ErnieOnTheRun
At (unexpected ?) system shutdown, I need to GUARANTEE that for a particular parent/ child process pair (the parent can have many children), the parent is killed FIRST.
|
Short answer: You cannot guarantee this.
An unexpected shut-down includes, for example, a power failure or hardware failure. I do assume you're not using an UPS (or similar) or are using a system that is fault tolerant (and even then it isn't fully guaranteed).
Quote:
At what point in time of the shutdown process are non-system processes killed ? I initially thought, it would be the /etc/init.d/killall script, but after experimenting, I found that non-system processes are killed already BEFORE the first script from run-level 6 is executed.
My conclusion is that this can NOT be done by adding/ configuring the init scripts.
I thought the VERY FIRST thing at "shutdown" that happens, is to move the run -level to 6 and then execute the scripts/ pull down routines specified.
At which point of the shutdown process are the processes killed that are already dead when the FIRST script in /etc/rc.d/rc6.d/ is run ? How can I manage them ?
Thanks a lot in advance.
|
You are talking about RL 6, which is used for rebooting, not shutting down a linux/unix box.
Have a look at the /etc/rc0.d directory. Those scripts will shut-down your box in an orderly fashion in the order shown.
The way this is actually done differs (slightly) on different distro's.
You could add your own kill script to the appropriate rc directories, this will make sure that your process is shut down properly when issuing a normal shut-down or reboot.
This might be a good read:
Learn Linux, 101: Runlevels, shutdown, and reboot