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:
Code:
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
process.
> 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).