Name
spawnv, spawnve
Synopsis
spawnv(mode
,path
,args
) spawnve(mode
,path
,args
,env
)
These functions run the program indicated by
path
in a new process
P
, with the arguments passed as sequence
args
. spawnve
uses
mapping env
as
P
’s environment (both
keys and values must be strings), while spawnv
uses os.environ
for this purpose. On Unix-like
platforms only, there are other variations of
os.spawn
, corresponding to variations of
os.exec
, but spawnv
and
spawnve
are the only two that exist on Windows.
mode
must be one of two attributes supplied by the os
module: os.P_WAIT
indicates that the calling
process waits until the new process terminates, while
os.P_NOWAIT
indicates that the calling process
continues executing simultaneously with the new process. When
mode
is os.P_WAIT
, the
function returns the termination code c
of
P
: 0
indicates
successful termination, c
less than
0
indicates P
was
killed by a signal
, and
c
greater than 0
indicates normal but unsuccessful termination. When
mode
is os.P_NOWAIT
,
the function returns P
’s
process ID (on Windows,
P
’s process handle).
There is no cross-platform way to use
P
’s ID or handle;
platform-specific ways (not covered further in this book) include
function os.waitpid
on Unix-like platforms and the
win32all
extensions (starship.python.net/crew/mhammond
) on
Windows.
For example, your interactive program can give the user a chance to edit a text file that your program is about to read and use. You must have previously determined the full path to the ...
Get Python in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.