title: using QTextStream to read stdin in a non-blocking fashion
body: <p>Using Qt, I'm attempting to read the contents of the stdin stream in a non-blocking fashion. I'm using the QSocketNotifier to alert me when the socket has recieved some new data. The setup for the notifier looks like this:</p>
  
  <pre><code>QSocketNotifier *pNot = new QSocketNotifier(STDIN_FILENO, QSocketNotifier::Read, this);
  connect(pNot, SIGNAL(activated(int)), this, SLOT(onData()));
  pNot-&gt;setEnabled(true);
  </code></pre>
  
  <p>The <code>onData()</code> slot looks like this:</p>
  
  <pre><code>void CIPCListener::onData()
  {
      qDebug() &lt;&lt; Q_FUNC_INFO;
      QTextStream stream(stdin, QIODevice::ReadOnly);
  
      QString str;
  
      forever
      {
          fd_set stdinfd;
          FD_ZERO( &amp;stdinfd );
          FD_SET( STDIN_FILENO, &amp;stdinfd );
          struct timeval tv;
          tv.tv_sec = 0;
          tv.tv_usec = 0;
          int ready = select( 1, &amp;stdinfd, NULL, NULL, &amp;tv );
          if( ready &gt; 0 )
          {
              str += stream.readLine();
          }
          else
          {
              break;
          }
      }
  
      qDebug() &lt;&lt; "Recieved data:" &lt;&lt; str;
  }
  </code></pre>
  
  <p>As you can see I'm attempting to use the select() system call to tell me when I've run out of data to read. However, in practise what is happening is the select() call returns 0 after I've read the first line of text. So, for example, if I write 5 lines of text to the process's stdin stream, I only ever read the first line.</p>
  
  <p>What could be the problem?</p>