Reputation: 252
how can i made a safe reboot like shell command reboot
from C without exec? The reboot function in reboot.h is not safe. It make no sync and probaly no unmount und safe process termination. What function have the magic parameter?
Bet regards
Upvotes: 0
Views: 3147
Reputation: 271
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). 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.
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.
Upvotes: 1
Reputation: 1048
The simplest way:
system('reboot')
Otherwise, you have Linux: Programatically shutdown or reboot computer from a user-level process
Upvotes: 1