Subject: Re: Kernel <-> init communication for shutdown
To: None <tech-kern@netbsd.org>
From: der Mouse <mouse@Rodents.Montreal.QC.CA>
List: tech-kern
Date: 01/14/2001 19:01:46
>> How about the following?

>> - Power button sends init SIGPWR
>> - Ctrl-Alt-Del (or platform equivalent if there is one) sends init SIGUSR1
>> - Other special key, if any, sends init SIGUSR2

>> on receipt of SIGPWR/SIGUSR1/SIGUSR2, [...]

Conceptually, I see nothing wrong with it.  I do think it's a bad idea
to assign a separate signal to each of three keys like this; the signal
space is very small and this hijacks a nontrivial fraction of it.  I'd
rather see some other way of communicating what magic button was hit.

I'm not sure what that way might be.  Some possibilities that come to
mind, of varying degrees of goodness:

- They all send the same signal, but with a magic identifier somewhere
   in the stuff that gets passed to the signal handler.

- They don't actually send a signal at all; init has a descriptor open
   (on /dev/hotkeys, perhaps, or maybe an AF_INIT socket), and magic
   keystrokes appear as input on that fd.

- They don't kick init directly; instead, they cause the kernel to
   hand-craft a new process, which execs an executable appropriate to
   the key hit.  If the executable doesn't exist, the key is
   effectively ignored.  (This executable may, if it wants, kick init,
   in any of numerous ways.)

					der Mouse

			       mouse@rodents.montreal.qc.ca
		     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B