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

QSocketNotifier with stdin fires activated() signal continuously on macOS

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • P2: Important
    • None
    • 5.9.0, 5.9.1, 5.9.2
    • Network: Sockets
    • None
    • macOS Sierra 10.12.6

      Qt 5.9.2 or earlier.
    • 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
          user-9b314
        2. main.cpp
          0.2 kB
          user-9b314
        3. mainwindow.cpp
          0.5 kB
          user-9b314
        4. mainwindow.h
          0.4 kB
          user-9b314
        5. mainwindow.ui
          0.6 kB
          user-9b314
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            tpochep Timur Pocheptsov
            jirauser43614 user-9b314 (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes