fork + thread = zombie ?

From: Thomas BOUTON (tbouton_at_streamwide.com)
Date: 02/25/04


Date: Wed, 25 Feb 2004 18:26:56 +0100

Hello all,

I am working on a multiprocess / multithreaded app supposed to run on
RedHat Linux Enterprise 3 WS.

Unfortunately, I stumble upon a bad problem: the following sequence
(simplified) generates a lot of zombie processes.

for(;;) {
        accept();

        if(fork()) {
                pthread_attr_setdetachstate(&pattr,PTHREAD_CREATE_DETACHED);
                pthread_create();
                // Do useful stuffs
                exit(0);
        }
}

I tried a set of signal handlers between SIG_IGN and SIG_DFL for both
parent and child processes, but I always end up with zombies, in some
cases, I even get 'undead' ones (i.e. zombies with init as a parent).

Is there anything I should do and forgot ?

thanks in advance,
        Thomas BOUTON
 



Relevant Pages

  • Re: process hangs on exit ?
    ... a process to terminate with no parent. ... parent terminates before the child, ... gets adopted by the init process. ... correctly, it returns 0, so the zombies will still be there. ...
    (comp.unix.solaris)
  • Re: is killing zombies possible w/o a reboot?
    ... >>ever had while running linux has only been disposable by a reboot. ... If you are talking about zombies who ... > has their parent alive, then it's a bug in the application, not the ... send the line "unsubscribe linux-kernel" in ...
    (Linux-Kernel)
  • Re: How to delete unix socket entries
    ... > Either these processes are running, or they're dead. ... > as parent and wait'ed them so they would be destroyed completely along ... I meant that these addresses behave like zombies, ...
    (freebsd-hackers)
  • Re: A problem with fork() and managing processes
    ... >zombies as long as the parent runs. ... The second-generation processes ... >don't become zombies because their parents are dead. ... sub busy; ...
    (comp.lang.perl.misc)
  • Re: SIGCHLD, fork() and sleep()
    ... Yes, it's a bit strange... ... > As I ignore SIGCHLD signal the children wont notify the parent ... notice the pending SIGCHLD signals for the parent (this is how signals ... set as the disposition, then discards the zombies ...
    (comp.unix.programmer)