subprocess.Popen objects: how to ensure that stdin is closed
v.harishankar at gmail.com
Fri Apr 2 06:17:55 EDT 2010
I am writing a small app which requires input using stdin to the
I use the following technique:
proc = subprocess.Popen (cmdargs, stdin=subprocess.PIPE)
proc.stdin.write ("something else")
and so on. I cannot use communicate() because it waits till program
termination and so obviously can be used once only.
The problem is that I want to close the process and it's not responding
either to proc.stdin.close() or even proc.terminate() which is in
Python 2.6 (not in 2.5.x)
So I am left with a mangled terminal.
Is subprocess behaving funny or am I doing something wrong? I am not even
sure if the proc.stdin.close () is respected because even without it, I
am getting the same mangled state. I just want to control the commands
using stdin.write and then close the process when done.
Harishankar (http://harishankar.org http://literaryforums.org)
More information about the Python-list