How to kill Zombie process?
greg at cosc.canterbury.ac.nz
Mon Dec 17 06:19:20 CET 2001
> ÕÅÉÙ³Û wrote:
> When I use ret=os.fork(),it will create a parent process and child
> process,when child process exists,it will creaet a Zombie process,How
> to kill it in parent's process?
A zombie process stays around until its parent process
either waits for it using the wait() system call or
one of its variants, or exits.
In a server process such as you seem to be implementing,
you need to do this asynchronously, which is a bit
tricky to get right. Briefly, you need to:
* Install a signal handler to catch the SIGCHLD signal,
which is sent whenever one of your child processes exits.
* In your signal handler, loop calling os.waitpid() with
the appropriate options to wait for any child process,
and not to block (see the Unix man page for waitpid(2)
for details). Keep calling waitpid() until it returns
indicating that there was no child process ready to be
Greg Ewing, Computer Science Dept, University of Canterbury,
Christchurch, New Zealand
To get my email address, please visit my web page:
More information about the Python-list