En Tue, 13 Feb 2007 01:52:57 -0300, <[EMAIL PROTECTED]>  
escribió:

> I'm new to Python and am evaluating moving a project from Tcl/Tk to
> Python and am stuck on one issue. How can I nohup (or any detached
> task for that matter) a process and get its PID in Python. The obvious
> route of (with a trivial example)
>
> os.system("nohup ls > junk &")
>
> returns the status of the command execution (ie. 0). I wish to get the
> PID output of the command (e.g. 16617). All the other commands spawn**
> also seem to return the execution status not the PID. This is a
> showstopper so any help appreciated.

The spawn* family will return the pid if you use the P_NOWAIT flag.
But the best way is to use the subprocess module; Popen objects have a pid  
attribute.

http://docs.python.org/lib/module-subprocess.html

-- 
Gabriel Genellina

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to