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 to restart the computer in other ways, but the choice needs to stay there. I've tried using system() to call the following:
- a suid-root shell script
- a non-suid shell script
- a suid-root binary program
and all of them just cause
reboot: must be superuserto be printed. Using system() to call reboot directly does the same thing. I'm not especially attached to using system() to do this, but it seemed like the most direct choice.
How can I reboot the system from the GUI?
Java socket bug on linux (0xFF sent, -3 received)
sendmail working but PHP mail() is failing
How do I stop/workaround Java apps stealing focus in Linux window managers
#define LINUX_REBOOT_CMD_POWER_OFF 0x4321fedc sync(); reboot(LINUX_REBOOT_CMD_POWER_OFF);
Lock a mutex multiple times in the same thread
How to profile my C++ application on linux
Running commands though PHP/Perl scripts as a priviledged user on Linux
Generating a reasonable ctags database for Boost
With any luck, that should pull up a modal dialogue to get user credentials..
gksudo shutdown -r
Where are my ruby gems?
rebootfunction is described in the Linux Programmer's Manual.
Under glibc, you can pass the
RB_AUTOBOOTmacro constant to perform the reboot.. Note that if
rebootis not preceded by a call to
sync, data may be lost.. Using glibc in Linux: .
#include <unistd.h> #include <sys/reboot.h> sync(); reboot(RB_AUTOBOOT);
"ksh -c 'sudo reboot'".
before system() call..
system( <however you wouuld do it from the command line> );