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

QSocketNotifier with stdin fires activated() signal continuously on macOS

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2: Important
    • Resolution: Invalid
    • Affects Version/s: 5.9.0, 5.9.1, 5.9.2
    • Fix Version/s: None
    • Component/s: Network: Sockets
    • Labels:
      None
    • Environment:
      macOS Sierra 10.12.6

      Qt 5.9.2 or earlier.
    • Platform/s:
      macOS

      Description

      When using QSocketNotifier with stdin under macOS the activated() signal fires continuously causing the CPU to spike to 100%. The same doesn't happen under Linux for example.

      The way it's used is pretty basic. You have a QSocketNotifier* m_notifier and you attach it to the signal/slot using the following way:

      m_notifier = new QSocketNotifier(fileno(stdin), QSocketNotifier::Read, this);
      connect(m_notifier, SIGNAL(activated(int)), this, SLOT(readMessages()));

       

      Even when the readMessages() function performs a blocking std::cin.read() it doesn't help at all. Something is clearly happening under macOS that is not correct.

       

        Attachments

        1. CMakeLists.txt
          0.5 kB
        2. main.cpp
          0.2 kB
        3. mainwindow.cpp
          0.5 kB
        4. mainwindow.h
          0.4 kB
        5. mainwindow.ui
          0.6 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            • Assignee:
              tpochep Timur Pocheptsov
              Reporter:
              varjolintu Sami Vänttinen
            • Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Gerrit Reviews

                There are no open Gerrit changes