tags:

views:

79

answers:

2

Hi, I'm working with an embedded board (a BeagleBoard), running a Linux distribution (Angstrom Linux). I would like to gently halt the operating system when a given button is pushed on the board. What I plan to do is :

  1. At the init, launch a "power-off" daemon as root user
  2. "power-off" run the magic code to check if a given button is pressed
  3. If the button is pressed, "power-off" call "halt"

Before jumping on my text-editor and code that, is there some standard Linux daemon to do that ?

A: 

I don't know the details of your board.. but take a look at the 'hal' daemon.

David Claridge
HAL is being phased out, fyi.
Conrad Meyer
+2  A: 

The init daemon (process ID 1) is set up to map the SIGWINCH signal to the kb ("keyboard request") action, which is free for you to define. init is what maps a ctrl-alt-del key press to a reboot; so it would make sense to have init handle your shutdown button too.

To implement this you just need to write a little kernel code to map your "shut down" button to send a SIGWINCH to PID 1, then set up the kb action to call shutdown -h in /etc/inittab.

caf