H
Harishankar
I am writing a small app which requires input using stdin to the
subprocess.
I use the following technique:
proc = subprocess.Popen (cmdargs, stdin=subprocess.PIPE)
proc.stdin.write ("Something")
proc.stdin.flush ()
....
proc.stdin.write ("something else")
proc.stdin.flush ()
....
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.
subprocess.
I use the following technique:
proc = subprocess.Popen (cmdargs, stdin=subprocess.PIPE)
proc.stdin.write ("Something")
proc.stdin.flush ()
....
proc.stdin.write ("something else")
proc.stdin.flush ()
....
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.