title: How can I find out why subprocess.Popen wait() waits forever if stdout=PIPE?
body: <p>I have a program that writes to stdout and possibly stderr. I want to run it from python, capturing the stdout and stderr. My code looks like:</p>
  
  <pre><code>from subprocess import *
  
  p = Popen( exe, shell=TRUE, stdout=PIPE, stderr=PIPE )
  rtrncode = p.wait()
  </code></pre>
  
  <p>For a couple of programs, this works fine, but when I added a new one, the new one hangs forever. If I remove <code>stdout=PIPE</code>, the program writes its output to the console and finishes and everything is fine. How can I determine what's causing the hang?</p>
  
  <p>Using python 2.5 on Windows XP. The program does not read from stdin nor does it have any kind of user input (i.e. "hit a key").</p>