March 27, 2012

Asperamanca Asperamanca
Hobby Entomologist
373 posts

[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)

  1. QProcess shellCommand;
  2. shellCommand.startDetached("reboot");

b)

  1. QProcess shellCommand;
  2. shellCommand.start("reboot");
  3. shellCommand.waitForFinished();

c)

  1. QProcess shellCommand;
  2. shellCommand.start("shutdown -r");
  3. shellCommand.waitForFinished();

d)

  1. QProcess shellCommand;
  2. shellCommand.start("sh -c reboot");
  3. 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

March 27, 2012

Asperamanca Asperamanca
Hobby Entomologist
373 posts

Note: My application uses about 80 % of the available system memory, which is all right because it’s the only application running.

Does QProcess consume a lot of memory?

March 28, 2012

blaroche blaroche
Lab Rat
32 posts

can you try using the full path to reboot or shutdown?

March 29, 2012

Asperamanca Asperamanca
Hobby Entomologist
373 posts

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.

March 29, 2012

thehilmisu thehilmisu
Lab Rat
35 posts

have you tried to add “0” to your shell command ? “shutdown -r 0”.

  1. QProcess shellCommand;
  2. shellCommand.start("shutdown -r 0");
  3. shellCommand.waitForFinished();

if it does not work, may be the problem cause that you are not the root.

March 29, 2012

Asperamanca Asperamanca
Hobby Entomologist
373 posts

I am root. And it used to work, before I expanded the buffers to use most of the available memory for archiving.

March 29, 2012

Luca Luca
Ant Farmer
589 posts

Suppose your command is in /usr/sbin/reboot you can try with:

  1. QProcess::startDetached("/usr/sbin/reboot");

March 30, 2012

Asperamanca Asperamanca
Hobby Entomologist
373 posts

My first try was based on startDetached. It seems to do a fork internally, too.

March 30, 2012

Luca Luca
Ant Farmer
589 posts

Have you tried with the full path of reboot command?

March 30, 2012

Asperamanca Asperamanca
Hobby Entomologist
373 posts

No. Plain Reboot used to work just fine. Colleagues with 20+ years of Unix experience assured me this is an underlying OS limitation.

 
  ‹‹ how to get street speed limit in Qt Mobility?      Qt application increases memory ››

You must log in to post a reply. Not a member yet? Register here!