View Full Version : Zombies and Multiprocessor???

12-13-2006, 10:02 PM
I am having a problem with fork() and the child processes becoming zombies.

I am using the code from the Advanced Linux Programming book that sets up a simple
web server that forks child processes to handle requests. This is all working OK but
when the child processes complete they are not being cleared correctly by the
signal handler clean up function that calls the wait() function.

I am wondering if there is anything that needs to be done beyond the code from
the book if this program is running on a Dual Processor machine?

Cheers in advance

12-13-2006, 10:35 PM
I have always had to use waitpid() to get the zombies gone.

12-13-2006, 11:07 PM

Just rechecked, and yes I am using wait() so will try waitpid() and get back to you.

Need to do some more readup on this call to make sure it does not break other things.

Thanks for the prompt reply.


12-14-2006, 04:48 PM

Tnx for that.

I changed the wait(&status) to waitpid((pid_t)-1, &status, 0) and seems to be working like a charm.

Once I have finished off some details I will publish what I was doing at:



01-05-2007, 05:07 PM
After letting the process run for a while longer it seems that the Zombie issue is not resolved correctly.

However I now have finished my webpage on the information for the Parallel Port Interface I constructed. Check out:



01-06-2007, 12:32 AM
Looks to me like you are missing some of the processes. . . pid_t would be a process number???? if so, then you are looking for the process number pid_t - 1, which wouldn't be the pid_t. . . If you want to clean up ANY zombie, you'd send -1 in stead of pid_t - 1, however, this would not tell you which process has ended. Here is a chunk from the man page:

The value of pid can be one of:

< -1 which means to wait for any child process whose process group ID is equal to the absolute value
of pid.

-1 which means to wait for any child process; this is the same behaviour which wait exhibits.

0 which means to wait for any child process whose process group ID is equal to that of the calling

> 0 which means to wait for the child whose process ID is equal to the value of pid.

Hope this helps! (BTW, from what I can recall [and it has been 10+ years] the process waitpid(-1, NULL, WNOHANG) would clean up all children that have returned).