title: Python, Popen and select - waiting for a process to terminate or a timeout
body: <p>I run a subprocess using:</p>
  
  <pre><code>  p = subprocess.Popen("subprocess", 
                         stdout=subprocess.PIPE, 
                         stderr=subprocess.PIPE, 
                         stdin=subprocess.PIPE)
  </code></pre>
  
  <p>This subprocess could either exit immediately with an error on stderr, or keep running. I want to detect either of these conditions - the latter by waiting for several seconds.</p>
  
  <p>I tried this:</p>
  
  <pre><code>  SECONDS_TO_WAIT = 10
    select.select([], 
                  [p.stdout, p.stderr], 
                  [p.stdout, p.stderr],
                  SECONDS_TO_WAIT)
  </code></pre>
  
  <p>but it just returns:</p>
  
  <pre><code>  ([],[],[])
  </code></pre>
  
  <p>on either condition. What can I do?</p>