Problem with running external process
Dan Sommers
me at privacy.net
Mon Jan 23 20:53:57 EST 2006
On 23 Jan 2006 10:03:28 -0800,
"ToMasz" <t_mo_info at o2.pl> wrote:
> Yes, each time the process is created, it remains. os.waitpid(-1,
> os.WNOHANG) doesn't work before starting the process for the first
> time.
Argh. That's what I get for looking at my example too quickly. ;-)
Of course: the best place for os.waitpid is immediately *after*
starting a new process. :-/
> I tried this:
> pid = os.fork()
> if pid == 0:
> os.execl('ext_script.py','ext_script.py')
> else:
> (pid,status) = os.waitpid(pid, 0)
> It seems to work without leaving zombies.
If your parent process just sits around and waits for each child process
to finish before moving on, why not use
os.spawnl(os.P_WAIT, 'ext_script.py')
instead of forking and execing "manually"?
Regards,
Dan
--
Dan Sommers
<http://www.tombstonezero.net/dan/>
More information about the Python-list
mailing list