managing multiple subprocesses

Donn Cave donn at drizzle.com
Fri Feb 4 02:16:07 EST 2005


Quoth Skip Montanaro <skip at pobox.com>:
| >>>>> "Marcos" == Marcos  <seejadee at gmail.com> writes:
|
|     Marcos> I have tried all sorts of popens / excevs / os.systems /
|     Marcos> commands etc etc. 
|
| I think os.spawn* and os.wait will do what you want.  I have trouble with
| os.spawn* myself, so may just fall back to fork/exec + os.wait in the
| parent.

That's probably the ticket.  There are endless variations on how you
can use these functions (especially if you include pipe() and the dup
fcntls), and in a way it may be simpler to write your own variation
than work with a packaged one that does approximately what you need.
As long as it doesn't need to run on Windows.

By the way, I never ever use the *p versions of these functions, and
always specify the full path of the executable.  I don't use the the
C library versions, and I don't use the Python versions.  The latter
aren't actually C library function wrappers, but rather like I think
most shells they contrive to look through PATH themselves, and at any
rate it's difficult to deal with the lookup failure in a useful way
in the child fork.  No doubt there are situations where a path lookup
is essential, but it just hasn't been happening to me.

	Donn Cave, donn at drizzle.com



More information about the Python-list mailing list