question about subprocess and shells

Lie Ryan lie.1296 at gmail.com
Fri Dec 4 17:53:41 EST 2009


On 12/5/2009 8:38 AM, Ross Boylan wrote:
> If one uses subprocess.Popen(args, ..., shell=True, ...)
>
> When args finishes execution, does the shell terminate?  Either way
> seems problematic.
>
> If it does not terminate, then it seems as if calls like wait and
> communicate would never return.  It also seems the subprocess would
> never die, and that most of the examples with the shell True would leave
> processes lying around.

No, p.wait() will immediately return, and p.communicate() discards 
everything new coming.

> If it does terminate, then how can you stuff new commands down the pipe
> to the subprocesses stdin?

start a new shell, of course.

> Does this module contemplate receiving multiple commands for the shell
> to execute?

yes, use several subprocess.Popen() or call a batch/shell script.



More information about the Python-list mailing list