[英]Safe reboot linux in C
how can i made a safe reboot like shell command reboot
from C without exec? 我如何在没有exec的情况下从C重新启动像shell命令一样安全的重新
reboot
? The reboot function in reboot.h is not safe. reboot.h中的重新启动功能不安全。 It make no sync and probaly no unmount und safe process termination.
它不进行同步,也可能不会进行卸载和安全的过程终止。 What function have the magic parameter?
哪些功能具有magic参数?
Bet regards 投注问候
The simplest way: 最简单的方法:
system('reboot')
Otherwise, you have Linux: Programatically shutdown or reboot computer from a user-level process 否则,您将拥有Linux:以编程方式从用户级进程关闭或重新启动计算机
In fact, there are systems in which reboot is done without properly unmounting partitions, causing filesystem errors. 实际上,有些系统在没有正确卸载分区的情况下完成了重新引导,从而导致文件系统错误。 For instance Android is only forcing filesystem to mount to read-only (by issuing "u" command to sysrq-trigger ).
例如,Android仅强制文件系统挂载为只读(通过向 sysrq-trigger 发出 “ u”命令)。 If you're not focused on performance and you rather want system to be shutdown cleanly, not quickly, then you need to perform following steps:
如果您不专注于性能,而是希望干净地,快速地关闭系统,那么您需要执行以下步骤:
All above steps you can do from C-code using calls like kill , umount , reboot . 您可以使用kill , umount , reboot等调用从C代码执行上述所有步骤。
As I said before, Android is not a best example in terms of clean shutdown, but you can have a look on example C-code shutdown implementation here . 如前所述,就干净关机而言,Android并不是最佳示例,但是您可以在此处查看示例C代码关机实现。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.