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

    • Bug
    • Resolution: Cannot Reproduce
    • Not Evaluated
    • None
    • 4.6.2
    • Core: I/O
    • None
    • 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

            thiago Thiago Macieira
            slava_phirsov phirsov
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes