do stuff after shutdown

ralda at gmx.de ralda at gmx.de
Tue Feb 28 08:14:56 UTC 2012


Hallo Laurent!

>  I am *only* suggesting that process 1 exiting should be taken as a
> hard reboot or poweroff instruction, instead of a panic instruction.

It looks to me, the problem is, that current code in kernel to do the
poweroff is run in a user process. If process 1 exits there is (or
shall be) no more user process to execute this code. Beside this
poweroff is not that simple as it ought to be. It has to shutdown the
hardware/system in the proper order which needs synchronization function
and other stuff running behalf a scheduled process. So implementing a
none panic behavior on process 1 exit would need to start a special
kernel thread for shutdown purpose. But what about this: When process 1
exits, is the system in a safe state that allows to start another
process to do any successful work? I ought you can't always answer this
question with a YES. So it is better to panic ... which reboots if so
configured.

... just some thoughts on that topic.

... but I ack, it would be a nice feature if kernel does a clean
poweroff if process 1 is EXITED (not terminated) with exit code Zero.
In any other case the panic seems to me the be best choice. A possible
argument to kernel developers would be: On small and dedicated systems
it is possible that the Linux kernel is more likely used like a
conventional single user DOS system. There you do not boot into a
conventional init process. Instead you run a program or script that
controls the systems behavior. On exit of that program/script (running
as process 1) the kernel shall do a clear poweroff without extra need
to code this at the end of the script.

--
Harald


More information about the busybox mailing list