[Python-Dev] Fork on Win32 - was (test_fork1 failing...)
Fredrik Lundh" <firstname.lastname@example.org
Fri, 28 Jul 2000 20:33:38 +0200
> BTW, (pardon my ignorance) what is the most portable way to
> do the equivalent of a os.system("cmd &") as native OS
> API call ? [On Unix, "cmd &" starts a new process which runs
> in the background and detached from the calling process.]
> I've looked at .execve and .spawnve, but they both replace
> the current process.
on windows, spawn(P_NOWAIT) does what you want. here's
an example from the eff-bot guide:
def run(program, *args, **kw):
# find executable
mode =3D kw.get("mode", os.P_WAIT)
for path in string.split(os.environ["PATH"], os.pathsep):
file =3D os.path.join(path, program) + ".exe"
return os.spawnv(mode, file, (file,) + args)
raise os.error, "cannot find executable"
run("python", "hello.py", mode=3Dos.P_NOWAIT)