[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: How does Linux shutdown?



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Wed, Jun 11, 2003 at 12:03:50PM -0400, Chun Kit Edwin Lau wrote:
> 	I am curious about how Linux does the shutdown.  The kernel send
> the TERM signal to all processes when the shutdown is initiated.  But
> does the kernel wait for the every process to finish before the kernel
> halt?  If not, will there be data lost then?

The kernel isn't sending that, I believe init does.  Going to runlevel
zero (shutdown), init runs scripts in /etc/rc0.d to cleanly shut down
daemons currently running.  When all those scripts are done, then it
sends a signal 15 (SIGTERM) to everything that's left.  Signal 15 is
basically like init getting on the PA system and announcing "OK,
everybody pack up and leave now!"  After a couple seconds, init sends
a signal 9 (SIGKILL) to what's left.  Programs cannot trap signal 9,
they immediately die.  Anything that's left after this is init and any
zombies that aren't running anyway, just sucking up space in the
process table.

Then the kernel punches the APM power switch shutting itself off or
prints a message to let you know nothing else is going to happen
(System halted) and hangs itself waiting for you to turn it off.

- -- 
 .''`.     Baloo Ursidae <baloo@ursine.ca>
: :'  :    proud Debian admin and user
`. `'`
  `-  Debian - when you have better things to do than fix a system
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)

iD8DBQE+6CRcJ5vLSqVpK2kRAlzUAJoDuC+bjlhyn4EXm1XSlO4NdiBllQCdFSpl
t1ZW3qZBxO2ChidS8ohI9Jk=
=Phsl
-----END PGP SIGNATURE-----



Reply to: