why does python.subprocess hang after proc.communicate()?
- by ccfenix
I've got an interactive program called my_own_exe. First, it prints out alive, then you input S\n and then it prints out alive again. Finally you input L\n. It does some processing and exits.
However, when I call it from the following python script, the program seemed to hang after printing out the first 'alive'.
Can anyone here tell me why this is happening?
Thanks
proc2 = subprocess.Popen("my_own_exe", shell=True , stdin=subprocess.PIPE, stdout=subprocess.PIPE)
print proc2.communicate()[0]
time.sleep(2);
print "alive" # 'hang' after print this line
proc2.communicate('S\n')[0]
print "alive"
print proc2.communicate()[0]
time.sleep(6)