Well, the example code at
http://www.python.org/doc/2.6.2/library/subprocess.html#replacing-shell-pipeline
has the same issue:
output=`dmesg | grep hda`
==>
p1 = Popen(["dmesg"], stdout=PIPE)
p2 = Popen(["grep", "hda"], stdin=p1.stdout, stdout=PIPE)
output = p2.communicate()[0]
After communicate
On Jan 6, 10:30 am, Nobody wrote:
> I think that you should close prog1.stdout here. Otherwise, there will
> be two readers on the pipe (the calling process and prog2). Even if one of
> them dies, there's always the possibility that the caller might eventually
> decide to read prog1.stdout itself.
BTW, I'm using Python 2.6.2 on Linux.
--
http://mail.python.org/mailman/listinfo/python-list
Below, I have a Python script that launches 2 child programs, prog1
and prog2, with prog1's stdout connected to prog2's stdin via a pipe.
(It's like executing "prog1 | prog2" in the shell.)
If both child programs exit with 0, then the script runs to
completion. But if prog2 exits with non-0, prog1