title: subprocess.Popen does not store exception to the errorfile
body: <p>I was trying to execute a python script from another python script, using subprocess.Popen. My command was:</p>
  
  <pre><code>outf = open('out.txt','w+')
  errf = open('err.txt','w+')
  p = subprocess.Popen([cmd],stdin=inf,stdout=outf,stderr=errf,shell=True)
  </code></pre>
  
  <p>all the required are defined previously. This has no problem for piping to the stdout file. But, when there are errors in the python script, it exits with an error. That error is neither stored in the stdout file nor the stderr file. What should I do to this?</p>
  
  <p>I get that the file exited because of an error, by using <code>p.returncode</code>. But how do I get the error traceback?</p>