title: Python subprocess.Popen.wait() returns 0 even though an error occured
body: <p>I am running a command line utility via Python's subprocess module.  I create a subprocess.Popen() object with the command line arguments and stdout=subprocess.PIPE and then I use subprocess.wait() to wait until the task is complete and to return the return code which should indicate whether the task completed successfully.</p>
  
  <pre><code>translate = subprocess.Popen(['gdal_translate', '-of', 'HFA', 'inDataset', 'outDataset'], stdout=subprocess.PIPE)
  if translate.wait() == 0: print "Success"
  else: print "Fail - %s" % translate.stdout.read()
  </code></pre>
  
  <p>If I run my script in the windows command prompt I can see the messages provided by gdal_translate and they say there were errors that cause a process to fail, but my script still prints "Success".</p>
  
  <p>How can I check for errors reported by the command line utility if the return code is always 0?</p>