Linux Processes from Python HOW-TO?

Michael Hudson mwh21 at cam.ac.uk
Fri Apr 28 19:17:53 EDT 2000


Thomas Wouters <thomas at xs4all.net> writes:

> > I'm really hoping someopne has written this up!
> 
> Well, I just did, didn't I ? ;) 

While I think this was a great write-up, I'll just add that Python has
fairly recently gained, in os.py, a bunch of functions that act a bit
like a cross between the os.exec* functions and os.system; the spawn*
functions.  They take a file and a list of arguments (like the exec*
functions) but the subprocess des not replace the calling process.  It
can either be run as a subprocess (a bit like popen, but you do not
control it's stdin or stdout) or you can ask the spawn* function to
wait for the process to return (a bit like system, but there is no
chance of the shell doing strange things to the arguments).  On
unices, these functions will most likely be implemented using
fork&execv, but they save some tedious boilerplate.

Cheers,
M.

-- 
6. Symmetry is a complexity-reducing concept (co-routines include
   subroutines); seek it everywhere.
      -- Alan Perlis, http://www.cs.yale.edu/~perlis-alan/quotes.html



More information about the Python-list mailing list