Defunct process

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I'm a new user of this group, and I don't know if it's the right group for
the post, any way the situation is:
I've got a C program used as a server listening on a tcp port. At any
request from a client there is a fork. Nothing strange. My problem is that
even if I use the waitpid function i've got a lots of defunct processes.
At first I use thise code:

struct sigaction sa;
struct sigaction osa;

sa.sa_handler = Reapear;
sigfillset (&sa.sa_mask);
sa.sa_flags = SA_NOCLDWAIT;

sigaction (SIGCHLD, &sa, &osa);

and this is the Reapear function:

void Reapear(int sig)
/*--------------------------------------------------------------------------
*/
{
static int i=0;
struct sigaction sa;
struct sigaction osa;

i++;
if(i > 200)
{
while(waitpid(-1, 0, WNOHANG) >= 0);
i = 0;
}

sa.sa_handler = Reapear;
sigfillset (&sa.sa_mask);
sa.sa_flags = SA_NOCLDWAIT;

sigaction (SIGCHLD, &sa, &osa);
}

I had the same problem on a Solaris system and resolved it using the
sigaction function (the old version used signal function), but it seems not
to have any effect on REDHAT 7.1 linux servers. Unfortunately I didn't wrote
the original code and so I've just found out that I had to change signal
into sigaction with the right structure as parameters but I don't understan
completely what Reapear function does...
Anyone can help me?
Than you very much
Andrea



-- 
redhat-list mailing list
unsubscribe mailto:redhat-list-request@xxxxxxxxxx?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list

[Index of Archives]     [CentOS]     [Kernel Development]     [PAM]     [Fedora Users]     [Red Hat Development]     [Big List of Linux Books]     [Linux Admin]     [Gimp]     [Asterisk PBX]     [Yosemite News]     [Red Hat Crash Utility]


  Powered by Linux