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. QProcess signal out of order ?
Forum Updated to NodeBB v4.3 + New Features

QProcess signal out of order ?

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 3 Posters 200 Views 3 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.
  • D Offline
    D Offline
    DalePennington
    wrote on 14 May 2025, 20:41 last edited by
    #1

    Folks,
    We have an application using QProcess to run an external command, in this case an untar command. We then process the output to provide status info by having a slot connected to readyReadStandardOutput that calls readAllStandardOutput and processes the data. We also have a slot connected to finished to detect when the command is complete. So we expected to start the process, get a series of readyReadStandardOutput signals to process and then the finished signal.

    This works fine on our development machine. But when we moved the app to a more powerful machine, we got some readyReadStandardOutputSignals, but then the finished signal followed by some more readyReadStandardOutput signals, which blew our initial assumptions.

    Is this expected behavior ? If so, why ? I might have expected one more (say we were processing one read while the app finished, and have one more readyReadStandardOutput after the finished signal to have the leftover data, but not multiples of them.

    Thanks,
    Dale Pennington

    J J 2 Replies Last reply 15 May 2025, 01:37
    0
    • D DalePennington
      14 May 2025, 20:41

      Folks,
      We have an application using QProcess to run an external command, in this case an untar command. We then process the output to provide status info by having a slot connected to readyReadStandardOutput that calls readAllStandardOutput and processes the data. We also have a slot connected to finished to detect when the command is complete. So we expected to start the process, get a series of readyReadStandardOutput signals to process and then the finished signal.

      This works fine on our development machine. But when we moved the app to a more powerful machine, we got some readyReadStandardOutputSignals, but then the finished signal followed by some more readyReadStandardOutput signals, which blew our initial assumptions.

      Is this expected behavior ? If so, why ? I might have expected one more (say we were processing one read while the app finished, and have one more readyReadStandardOutput after the finished signal to have the leftover data, but not multiples of them.

      Thanks,
      Dale Pennington

      J Offline
      J Offline
      jeremy_k
      wrote on 15 May 2025, 01:37 last edited by
      #2

      @DalePennington said in QProcess signal out of order ?:

      I might have expected one more (say we were processing one read while the app finished, and have one more readyReadStandardOutput after the finished signal to have the leftover data, but not multiples of them.

      What version of Qt, and what platform is involved?

      Is there a nested event loop, or a connection to a slot in another thread?

      Asking a question about code? http://eel.is/iso-c++/testcase/

      1 Reply Last reply
      0
      • D Offline
        D Offline
        DalePennington
        wrote on 15 May 2025, 13:20 last edited by
        #3

        This is Qt5 (5.12.5 in particular) on Red Hat Linux 8.4. We are not using any QThreads in this application, so its the signal GUI thread with the default event processing.

        Dale

        1 Reply Last reply
        0
        • D DalePennington
          14 May 2025, 20:41

          Folks,
          We have an application using QProcess to run an external command, in this case an untar command. We then process the output to provide status info by having a slot connected to readyReadStandardOutput that calls readAllStandardOutput and processes the data. We also have a slot connected to finished to detect when the command is complete. So we expected to start the process, get a series of readyReadStandardOutput signals to process and then the finished signal.

          This works fine on our development machine. But when we moved the app to a more powerful machine, we got some readyReadStandardOutputSignals, but then the finished signal followed by some more readyReadStandardOutput signals, which blew our initial assumptions.

          Is this expected behavior ? If so, why ? I might have expected one more (say we were processing one read while the app finished, and have one more readyReadStandardOutput after the finished signal to have the leftover data, but not multiples of them.

          Thanks,
          Dale Pennington

          J Offline
          J Offline
          JonB
          wrote on 15 May 2025, 17:25 last edited by
          #4

          @DalePennington
          @jeremy_k may know more about the internals of QProcess than I, but I would not expect to guarantee that all output would be received before the finished signal.

          Assuming finished corresponds to to the subprocess exiting, it is quite possible to receive final output after that. It depends on (OS) buffering of output pipes, and when that occurs/they get flushed relative to subprocess exit.

          You might look at Qt's internal implementation of its blocking subprocess calls, I forget what they are but something like QProcess::exec() et al. They return when subprocess exits and you can still read output from process.

          As for

          one more readyReadStandardOutput after the finished signal to have the leftover data, but not multiples of them.

          I would not read any guarantees into how often readReads signals are raised relative to input flow/"left over data".

          I admit, thinking about it, this raises an interesting question as to how you are supposed to know for sure when no more output can be received versus program exit time. Usually the pipe would be closed when end of incoming data is received, rather than depending on exit instant.

          1 Reply Last reply
          0
          • J Offline
            J Offline
            jeremy_k
            wrote on 15 May 2025, 17:43 last edited by
            #5

            How about the nested event loop question? I ask because:

            we were processing one read while the app finished

            This implies notification that the process has exited. Otherwise, the process is a metaphorical cat in a box. If that notification happens while executing a slot connected to readyReadStandardOutput(), additional emissions of the readyRead signal won't have had a chance to fire.

            Asking a question about code? http://eel.is/iso-c++/testcase/

            1 Reply Last reply
            0
            • D Offline
              D Offline
              DalePennington
              wrote on 15 May 2025, 20:42 last edited by
              #6

              Actually, I expected that one more signal would occur if the readyReadStandardOutput was processing while the process finished. The odd thing was there was a second readyReadStandardOutput signal happening. Although I have checked with the guy doing the actual work, and the second one always returns an empty string when readAllStandardOutput is called.

              1 Reply Last reply
              0

              1/6

              14 May 2025, 20:41

              • Login

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