[Solved] Reboot on Linux embedded
I am trying to reboot a linux embedded device using QProcess.
I have tried various ways, and none of them seem to work:
a)
- QProcess shellCommand;
- shellCommand.startDetached("reboot");
b)
- QProcess shellCommand;
- shellCommand.start("reboot");
- shellCommand.waitForFinished();
c)
- QProcess shellCommand;
- shellCommand.start("shutdown -r");
- shellCommand.waitForFinished();
d)
- QProcess shellCommand;
- shellCommand.start("sh -c reboot");
- shellCommand.waitForFinished();
I have tested all the command using telnet. Every one of them reboots the system.
I have also ensured that my application runs as root.
The QProcess in attempts b) to d) always exits with “NormalExit”, and an exit code of zero.
Ideas?
9 replies
I think I know what’s the problem:
The fork that must be somewhere inside QProcess can’t work, because there isn’t enough memory left to fork the current application. Why I wouldn’t get an error state I don’t know.
I have solved this by having a worker script run in an endless loop that will execute any shell script following a specific naming convention. I create a script containing the reboot command, and let it execute.
have you tried to add “0” to your shell command ? “shutdown -r 0”.
- QProcess shellCommand;
- shellCommand.start("shutdown -r 0");
- shellCommand.waitForFinished();
if it does not work, may be the problem cause that you are not the root.
You must log in to post a reply. Not a member yet? Register here!



