Subject: Re: The right place for doshutdownhooks()
To: Greg Hudson <ghudson@MIT.EDU>
From: Chris G Demetriou <Chris_G_Demetriou@BALVENIE.PDL.CS.CMU.EDU>
List: tech-kern
Date: 11/19/1995 21:35:16
> So, after it was expressed that doshutdownhooks() was allegedly in the
> wrong place in arch/i386/machdep.c, I took a look at the code I
> checked in.  Currently, in the i386 port doshutdownhooks() is run
> after the key is pressed for "press any key to reboot" (if it's a
> halt), and after a dump (if any).  In the alpha port,
> doshutdownhooks() is run after a dump (if any) but before a key is
> pressed for "press any key to reboot".

No, in the alpha port, for a while now, it's been run right after
'haltsys', i.e. right before printing that the system is going to halt
or reboot.  (and, it happens regardless of whether or not the system
is 'cold', so, they always get run, unless the system is powered off.)

Don't assume that the alpha code in the master source tree is anywhere
near up to date.  It's not worth my time to keep it up to date,
especially given the luke-warm reaction i've received to getting some
of the rest of the 64-bit fixes in.

> 	* The shutdown handlers might actually shut down the console
> 	  driver in some circumstances, rendering it impossible for
> 	  the user to press a key.
> Disagreements?  Thoughts?

I think this is unreasonable.

If the shutdown handlers shut down the console driver, then:
	(1) it's not guaranteed that all shutdown handlers can
		actually print things to the console, which
		i think is a big bummer, and,

	(2) you can't ever honestly say "the system is now halting."

Re: the latter:

the alpha port says "halted." or "rebooting..." right before it
transfers control to the firmware.  If you add a (potentially
infinite) amount of code between then and when you actually _do_ halt
or reboot, it makes debugging the halt/reboot process that much
harder.  (in particular, for a long time i was tracking down a problem
that caused the console firmware to crash(!!), and if there were a lot
of code between the "halting" message and the return to the firmware,
it would have been harder to track down.)

In what circumstance is it useful to have a shutdown hook disable
the console?