how to start a process and get it's pid?

Gerhard Häring gh at ghaering.de
Fri Nov 11 04:18:30 EST 2005


Yves Glodt wrote:
> Hello,
> 
> another question rose for me today...
> 
> Is there a way to start an external process, in it's own context (not as 
> the exec-() functions do), and get it's pid...? [...]

Check out the subprocess module if you're using Python 2.4.

Otherwise, you can always use os.spawn*, for example:

 >>> os.spawnl(os.P_NOWAIT, "c:/windows/notepad.exe")
1944

HTH,

-- Gerhard




More information about the Python-list mailing list