3

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 ?

snakile
  • 52,936
  • 62
  • 169
  • 241
Monkey
  • 1,838
  • 1
  • 17
  • 24
  • This would be a better question for Serverfault. Its more of a scripting question and dealing with runlevels. – monksy Nov 27 '09 at 04:29
  • I see more my question as an architecture related one : I can do it, but I'm not sure it's the right way, due to my limited experience with embedded boards. – Monkey Nov 27 '09 at 05:10

2 Answers2

2

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
  • 233,326
  • 40
  • 323
  • 462
0

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

David Claridge
  • 6,159
  • 2
  • 27
  • 25