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

Warning "Invalid socket XX and type 'Read', disabling..." issued when QProcess is restarted from slot connected to QProcess::stateChanged

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Reported
    • Priority: Not Evaluated
    • Resolution: Unresolved
    • Affects Version/s: 4.6.2
    • Fix Version/s: None
    • Component/s: Core: I/O
    • Labels:
      None
    • Environment:
      GNU/Linux CentOS Release 6.4 (Final)

      Description

      consider such a code snippet:

      #include <QCoreApplication>
      #include <QStringList>
      #include <QObject>
      #include <QProcess>
      #include <QtDebug>
      
      
      class Foo: public QObject
      {
          Q_OBJECT
      public:
      
          Foo(QObject* parent=0):
              QObject(parent)
          {
              _coprocess = new QProcess(this);
      
              _coprocess->setProcessChannelMode(QProcess::ForwardedChannels);
      
              this->connect(
                  _coprocess, SIGNAL(stateChanged(QProcess::ProcessState)),
                  SLOT(onCoprocessStateChanged(QProcess::ProcessState))
              );
          }
      
          void startCoprocess()
          {
              _coprocess->start("ps");
          }
      
      private slots:
      
          void onCoprocessStateChanged(QProcess::ProcessState state)
          {
              qDebug() << "coprocess state changed to" << state;
      
              if (state == QProcess::NotRunning)
                  startCoprocess();
          }
      
      private:
          QProcess* _coprocess;
      };
      
      
      int main(int argc, char* argv[])
      {
          QCoreApplication app(argc, argv);
      
          Foo foo;
      
          foo.startCoprocess();
      
          return app.exec();
      }
      
      
      #include "main.moc"
      

      the output is:

      coprocess state changed to 1 
      coprocess state changed to 2 
        PID TTY          TIME CMD
       7263 pts/6    00:00:00 bash
       7534 pts/6    00:00:00 qprocess-restar
       7536 pts/6    00:00:00 ps
      coprocess state changed to 0 
      coprocess state changed to 1 
      QSocketNotifier: Invalid socket 15 and type 'Read', disabling...
        PID TTY          TIME CMD
       7263 pts/6    00:00:00 bash
       7534 pts/6    00:00:00 qprocess-restar
       7537 pts/6    00:00:00 ps
      

      and the coprocess is not restarted continiously each time it's state changed to QProcess::NotRunning, as expected.

        Attachments

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

          Activity

            People

            Assignee:
            Unassigned
            Reporter:
            slava_phirsov phirsov
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:

                Gerrit Reviews

                There are no open Gerrit changes