#include <unistd.h>
#include <linux/reboot.h>


int main() {
    reboot(LINUX_REBOOT_MAGIC1, 
           LINUX_REBOOT_MAGIC2, 
           LINUX_REBOOT_CMD_POWER_OFF, 0);
    //   sync();
    //    reboot(LINUX_REBOOT_CMD_POWER_OFF);
}
Of course, you will need sufficient privileges to use this syscall.
必须有root权限哦

posted on 2017-11-20 20:06  未雨愁眸  阅读(485)  评论(0编辑  收藏  举报