Running shell programs from Python

Garry Hodgson garry at sage.att.com
Mon Apr 24 13:34:32 EDT 2000


Donn Cave wrote:

> The references are mainly UNIX man pages pipe(2), fork(2), fcntl(2)
> (look for dup2), exec(2) and wait(2).
> 
> Basically, the sequence is repeat ( open pipes, fork, close pipes )
> After a fork, the parent and child both have both ends of each pipe
> open, and it's important to close the unused "write" ends so the
> pipe will generate an EOF when its real writer exits.

i've always been curious why this wasn't encapsulated as a single
command in the os module.  i use it infrequently enough that i always
need to go look the idiom, or skip it for simpler things.  seems like
a single command that returned a process id, and a pair of file
descriptors would have lots of uses.

-- 
Garry Hodgson                   Every night 
garry at sage.att.com                a child is born
Software Innovation Services        is a Holy Night.
AT&T Labs                         - Sophia Lyon Fahs



More information about the Python-list mailing list