title: Python freezing on unexpected CL output with subprocess module
body: <p>I am writing a script to get version numbers from command line programs by using their appropriate 'version' command line flag i.e. --version, -v etc. The program as a whole uses a regex to get just the actual version number from the text output and then compares it to various conditions of minimum required or maximum allowed version pulled from an xml conf file etc.</p>
  
  <p>The script works perfectly until executing bzip2.</p>
  
  <p>For most programs there is no issue with the following code:</p>
  
  <pre><code>args = 'cmd --version'
  
  output = subprocess.getstatusoutput(args)
  </code></pre>
  
  <p>pretty cut and dry. However! If you try this with, say, bzip2 (and so far this is the only program I've had an issue with) ala 'bzip2 --version' python "freezes" and you must ctrl-C to break out with no output recorded of course.</p>
  
  <p>I've tried various variations such as going the long route i.e.:</p>
  
  <pre><code>import subprocess
  from subprocess import PIPE, STDOUT
  
  proc = subprocess.Popen(args, stdout=PIPE, stderr=STDOUT)
  while(True):
      code = proc.poll()
      if(code is not None):
          break
      line = proc.stdout.readline() # or even read()
      etc.
  </code></pre>
  
  <p>Regardless of which method I use to extract the relevant text, Python always hangs after a certain point. I've tried .kill() at certain points to head off the locking event but to no avail.</p>
  
  <p>It's just with bzip2 I think because for some reason it's still expecting input with the --version flag.</p>
  
  <p>Any thoughts?</p>