I have a Qt 4 GUI where I need to have a option in a drop-down menu that allows the user to choose to restart the computer. I realize this might seem redunant with the ability t
This should do it on almost any linux system.
#include
#include
int main () {
sync();
setuid(0);
reboot(RB_AUTOBOOT);
return(0);
}
Then just compile with gcc reboot.c -o reboot
and do chmod a+s reboot
on the binary. Then call reboot as any user and the system should reboot smoothly. The way you do this through your GUI varies, as in if your Desktop Environment was KDE for example, it's quite different than doing the same thing under Fluxbox.