Hi all --
it recently occured to me that the 'spawn' module I wrote for the
Distutils (and which Perry Stoll extended to handle NT), could fit
nicely in the core library. On Unix, it's just a front-end to
fork-and-exec; on NT, it's a front-end to spawnv(). In either case,
it's just enough code (and just tricky enough code) that not everybody
should have to duplicate it for their own uses.
The basic idea is this:
from spawn import spawn
spawn (['cmd', 'arg1', 'arg2'])
spawn (['cmd'] + args)
you get the idea: it takes a *list* representing the command to spawn:
no strings to parse, no shells to get in the way, no sneaky
meta-characters ruining your day, draining your efficiency, or
compromising your security. (Conversely, no pipelines, redirection,
The 'spawn()' function just calls '_spawn_posix()' or '_spawn_nt()'
depending on os.name. Additionally, it takes a couple of optional
keyword arguments (all booleans): 'search_path', 'verbose', and
'dry_run', which do pretty much what you'd expect.
The module as it's currently in the Distutils code is attached. Let me
know what you think...
Greg Ward - software developer gward(a)cnri.reston.va.us
Corporation for National Research Initiatives
1895 Preston White Drive voice: +1-703-620-8990
Reston, Virginia, USA 20191-5434 fax: +1-703-620-0913