The following code can be used to actively restart the system machine.
#include<unistd.h> #include<sys/reboot.h>
//Synchronize data and save cached data to prevent data loss sync(); reboot(RB_AUTOBOOT);