Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Restart QProcess
Qt 6.11 is out! See what's new in the release blog

Restart QProcess

Scheduled Pinned Locked Moved General and Desktop
7 Posts 3 Posters 7.7k Views 1 Watching
  • 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.
  • S Offline
    S Offline
    saaleb
    wrote on last edited by
    #1

    Hi,

    I need to launch a number of external programs from QT application and monitor their state, in case of crashing program need to be restarted. (Linux platform only)
    So I found QProcess most useful for this, but have a problem - when I get onError signal from QProcess instance, I can't re-run it with the same parameters, as process still in QProcess::Running state.

    I will be very thankful for any advice regarding QProcess re-run thick or may be any more useful way to manage processes

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mcosta
      wrote on last edited by
      #2

      Hi,

      once you received error signal with Crashed value, you can call kill() and then re-run it

      Once your problem is solved don't forget to:

      • Mark the thread as SOLVED using the Topic Tool menu
      • Vote up the answer(s) that helped you to solve the issue

      You can embed images using (http://imgur.com/) or (http://postimage.org/)

      1 Reply Last reply
      0
      • S Offline
        S Offline
        saaleb
        wrote on last edited by
        #3

        [quote author="mcosta" date="1364211388"]Hi,

        once you received error signal with Crashed value, you can call kill() and then re-run it
        [/quote]

        It's not work.

        Even after kill() or terminate() QProcess state equals to QProcess::Running and trying to
        call start() will give you:
        QProcess::start: Process is already running

        I don't know, may be I'm using QProcess wrong, but it looks like a bug. Sending SIGTERM or SIGINT to external process raise only onError() signal, but state of QProcess leaves as running.
        I tried to extend QProcess with my own class and set NotRunning state manually(I know thats not correct, just for test), but QProcess also give me warning message.

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mcosta
          wrote on last edited by
          #4

          Strange,

          when you receive error() signal, what is the error value?
          Are you sure is "Crashed"??

          Can you post you code please?

          Once your problem is solved don't forget to:

          • Mark the thread as SOLVED using the Topic Tool menu
          • Vote up the answer(s) that helped you to solve the issue

          You can embed images using (http://imgur.com/) or (http://postimage.org/)

          1 Reply Last reply
          0
          • S Offline
            S Offline
            saaleb
            wrote on last edited by
            #5

            Looks like I found a root cause of issue. The reason is a delayed state change after kill, looks like it need to spend some main loop cycles for make QProcess object state actually changed.

            Thanks for helping, it just need a fresh head! )

            1 Reply Last reply
            0
            • M Offline
              M Offline
              mcosta
              wrote on last edited by
              #6

              Hi, you can use QProcess::waitForFinished() for this purpose or catch finished() signal

              Once your problem is solved don't forget to:

              • Mark the thread as SOLVED using the Topic Tool menu
              • Vote up the answer(s) that helped you to solve the issue

              You can embed images using (http://imgur.com/) or (http://postimage.org/)

              1 Reply Last reply
              0
              • J.FuJ Offline
                J.FuJ Offline
                J.Fu
                wrote on last edited by J.Fu
                #7

                use this:

                if(normalAppProcess.state() == QProcess::NotRunning)
                {
                normalAppProcess.start("address to your app");
                }

                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