title: Correct Code - Non-blocking pipe with popen
body: <p>There are tons of questions about non blocking pipes, but there are NO examples of code that can be copy&amp;paste (with little correction) and used.</p>
  
  <p>I got the idea and sources from this thread:
  <a href="https://stackoverflow.com/questions/1735781/non-blocking-pipe-using-popen">Non-blocking pipe using popen?</a></p>
  
  <p>But how to use it? At <code>while</code> cycle?  Please, review my changes. Is it really need to use <code>errno == EAGAIN</code> &amp;  additional header <code>#include &lt;cerrno&gt;</code> ?
  Suggest you own better version if need:</p>
  
  <pre><code>    FILE *pipe;
      char buff[512];
      if ( !(pipe = popen( command.c_str(), "r")) ) return false;
  
      int d = fileno(pipe);   
      while ( true )
      {
          ssize_t r = read(d, buff, sizeof(buff));
          if (r == -1 &amp;&amp; errno == EAGAIN) // really need errno? 
              continue;
          else if (r &gt; 0)
              ptr_output-&gt;append(buff);       
          else
              break;
      }
  
      pclose(pipe);
  </code></pre>