How to tell if a forked process is done?

François Pinard pinard at iro.umontreal.ca
Tue Sep 23 21:06:31 EDT 2003


[John Lin]
> I want to know how to tell if a forked process is done.

A few people suggested `os.system()' already, and I presume this is what
you want and need.

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.

-- 
François Pinard   http://www.iro.umontreal.ca/~pinard





More information about the Python-list mailing list