处理嵌入式板的断电
我正在使用嵌入式板(BeagleBoard),运行Linux发行版(Angstrom Linux)。当按下板上的给定按钮时,我想轻轻地停止操作系统。我计划做的是:
- 在 init 处,以 root 用户“关闭电源”身份启动
- “关闭电源”守护进程,运行魔术代码来检查是否按下了给定的按钮
- 如果按下按钮,则“关闭电源”调用“halt”
在使用我的文本编辑器并编写代码之前,是否有一些标准的 Linux 守护进程可以做到这一点?
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 :
- At the init, launch a "power-off" daemon as root user
- "power-off" run the magic code to check if a given button is pressed
- 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 ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
init
守护进程(进程 ID 1)被设置为将SIGWINCH
信号映射到kb
(“键盘请求”)操作,该操作是免费供您定义。init
是将 ctrl-alt-del 按键映射到重新启动;所以让init
处理你的关机按钮也是有意义的。要实现这一点,您只需编写一些内核代码来映射“关闭”按钮,以将
SIGWINCH
发送到 PID 1,然后设置要调用的kb
操作/etc/inittab
中的shutdown -h
。The
init
daemon (process ID 1) is set up to map theSIGWINCH
signal to thekb
("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 haveinit
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 thekb
action to callshutdown -h
in/etc/inittab
.我不知道你的主板的详细信息..但看看“hal”守护进程。
I don't know the details of your board.. but take a look at the 'hal' daemon.