title: why does python.subprocess hang after proc.communicate()?
body: <p>I've got an interactive program called <code>my_own_exe</code>. First, it prints out <code>alive</code>, then you input <code>S\n</code> and then it prints out <code>alive</code> again. Finally you input <code>L\n</code>. It does some processing and exits.</p>
  
  <p>However, when I call it from the following python script, the program seemed to hang after printing out the first 'alive'.</p>
  
  <p>Can anyone here tell me why this is happening?</p>
  
  <p>// after reading the follow ups (thank you guys), i modified the code as following:</p>
  
  <pre><code>import subprocess
  import time
  
  base_command = "./AO_FelixStrategy_UnitTest --bats 31441 --chix 12467 --enxutp 31884 --turq 26372 --symbol SOGN --target_date " + '2009-Oct-16'
  print base_command
  
  proc2 = subprocess.Popen(base_command, shell=True , stdin=subprocess.PIPE,)
  
  time.sleep(2);
  print "aliv"
  proc2.communicate('S\n')
  
  print "alive"
  time.sleep(6)
  
  print "alive"
  print proc2.communicate('L\n')
  time.sleep(6)
  </code></pre>
  
  <p>the program now goes well with the first input 'S\n', but then stopped, and I the second 'L\n' is kinda ignored.</p>
  
  <p>Can anyone give me an idea why it's like this?</p>