Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. [Solved] Reboot on Linux embedded
QtWS25 Last Chance

[Solved] Reboot on Linux embedded

Scheduled Pinned Locked Moved Mobile and Embedded
10 Posts 4 Posters 8.8k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Asperamanca
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      Asperamanca
      wrote on last edited by
      #2

      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?

      1 Reply Last reply
      0
      • B Offline
        B Offline
        blaroche
        wrote on last edited by
        #3

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

        1 Reply Last reply
        0
        • A Offline
          A Offline
          Asperamanca
          wrote on last edited by
          #4

          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.

          1 Reply Last reply
          0
          • T Offline
            T Offline
            thehilmisu
            wrote on last edited by
            #5

            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.

            1 Reply Last reply
            0
            • A Offline
              A Offline
              Asperamanca
              wrote on last edited by
              #6

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

              1 Reply Last reply
              0
              • L Offline
                L Offline
                luca
                wrote on last edited by
                #7

                Suppose your command is in /usr/sbin/reboot you can try with:
                @
                QProcess::startDetached("/usr/sbin/reboot");
                @

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  Asperamanca
                  wrote on last edited by
                  #8

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

                  1 Reply Last reply
                  0
                  • L Offline
                    L Offline
                    luca
                    wrote on last edited by
                    #9

                    Have you tried with the full path of reboot command?

                    1 Reply Last reply
                    0
                    • A Offline
                      A Offline
                      Asperamanca
                      wrote on last edited by
                      #10

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

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved