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