How to tell if a forked process is done?

Klaus Alexander Seistrup spam at magnetic-ink.dk
Wed Sep 24 08:27:41 CEST 2003


François Pinard wrote:

> In the less usual case you want concurrency between Python and the
> forked shell command,  for only later checking if the forked process
> is done, the usual way is to send a zero signal to the child using
> `os.kill()'.  The zero signal would not do any damage in case your
> forked process is still running.  But if the process does not exist,
> the parent will get an exception for the `os.kill()', which you may
> intercept.  So you know if the child is running or finished.

This will yield a false positive and potential damage if the OS has
spawned another process with the same pid, and running under your uid,
as the task you wanted to supervise.


  // Klaus

-- 
 ><> 	unselfish actions pay back better




More information about the Python-list mailing list