ubuntu c++ 关机 重启 挂起 API

#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权限哦

原文地址:https://www.cnblogs.com/mtcnn/p/9410027.html