Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-39488

mac: CFRunLoop/CFSocket incompatible with select() on the same socket



    • Bug
    • Status: Closed
    • P2: Important
    • Resolution: Done
    • 4.7.0, 5.3.0
    • 5.3.1
    • Core: I/O
    • None
    • macOS
    • 3ccfc351fdcbb117e2872229382e45a929dac62a


      This problem is similar to the Blackberry problem.

      Whenever we create a CFSocket in qcfsocketnotifier.cpp (due to the Cocoa-based event loop for the GUI thread), it registers the socket for notification with an outside source (kevent, threads, whatever). That is incompatible with the select()-based loop we have in qprocess_unix.cpp.

      The attached "bad" output of dtruss shows that the following happens (note, dtruss output is not ordered, you should sort by thread CPU time):

      1. parent process stops in select(), waiting for input from child (this is QProcess::waitForReadyRead)
      2. child process writes "hello world"
      3. parent process reads, first by doing an ioctl with FIONREAD
      4. parent process goes into the CFRunLoop-based processEvents()
      5. the socket notifier for the stdout channel is activated
      6. parent process tries to read, but this time ioctl reported 0 bytes available
      7. parent process closes stdout channel
      8. child process writes to stdout and gets EPIPE and dies from SIGPIPE


        1. main.cpp
          0.7 kB
        2. process_exit_bad.log
          160 kB
        3. process_exit_good.log
          60 kB

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.



              thiago Thiago Macieira
              buddenha Oswald Buddenhagen
              0 Vote for this issue
              4 Start watching this issue



                Gerrit Reviews

                  There are no open Gerrit changes