zombie process.

  • Follow


Hi all, 

I have handeled the SIGCHLD using waitpid as, 

void sigchld_handler(int s)
{
    int pid, status = 0;
    while((pid = waitpid(-1, &status, WNOHANG)) > 0){
        if(WIFSIGNALED(status)) {
            fprintf(stdout, "kid: %d terminated with status: %d\n",
pid, status);
        }
        fprintf(stdout, "Kid exit status: %d\n", pid);
    }  
}

The same handler is used every where for handling kids reaping.
Waitpid will reap all the process that have died when its called.

In one program,  when several processes exit together I see zombies
getting created and getting reaped, so that is perfectly fine.

But in another program, I see only zombie process. This processes
accepts connection on socket and give the data to the parent which
then writes it on to mysql server using mysql client library.

Any guesses wht's going wrong.
0
Reply pradeep 3/3/2005 4:57:31 AM

"Pradeep" <pradeep@mauj.com> wrote in message 
news:3ffc09d1.0503022057.1de4280e@posting.google.com...
> Hi all,
>
> I have handeled the SIGCHLD using waitpid as,
>
> void sigchld_handler(int s)
> {
>    int pid, status = 0;
>    while((pid = waitpid(-1, &status, WNOHANG)) > 0){
>        if(WIFSIGNALED(status)) {
>            fprintf(stdout, "kid: %d terminated with status: %d\n",
> pid, status);
>        }
>        fprintf(stdout, "Kid exit status: %d\n", pid);
>    }
> }
>
> The same handler is used every where for handling kids reaping.
> Waitpid will reap all the process that have died when its called.
>
> In one program,  when several processes exit together I see zombies
> getting created and getting reaped, so that is perfectly fine.
>
> But in another program, I see only zombie process. This processes
> accepts connection on socket and give the data to the parent which
> then writes it on to mysql server using mysql client library.
>
> Any guesses wht's going wrong.

waitpid() can return -1 for reasons other than ECHILD.  One of these reasons 
is EINTR.  You need to examine errno after a -1 return and decide whether or 
not to re-enter waitpid().

--

Fletcher Glenn 


0
Reply Fletcher 3/3/2005 5:32:57 PM


1 Replies
175 Views

(page loaded in 0.047 seconds)

Similiar Articles:













7/14/2012 12:46:09 AM


Reply: