Return-Path: Delivered-To: apmail-apr-dev-archive@apr.apache.org Received: (qmail 3479 invoked by uid 500); 21 May 2002 14:56:14 -0000 Mailing-List: contact dev-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Delivered-To: mailing list dev@apr.apache.org Received: (qmail 3468 invoked from network); 21 May 2002 14:56:13 -0000 X-Authentication-Warning: rdu88-251-253.nc.rr.com: trawick set sender to trawick@attglobal.net using -f Sender: trawick@rdu88-251-253.nc.rr.com To: dev@apr.apache.org Subject: [PATCH] PR 9168 don't leave zombie processes on Mac OS X with mod_cgid From: Jeff Trawick Date: 21 May 2002 10:58:58 -0400 Message-ID: Lines: 49 User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N mod_cgid does apr_signal(SIGCHLD, SIG_IGN)... assuming that we want this to avoid zombies, does anybody have a better solution than the following? Index: srclib/apr/threadproc/unix/signals.c =================================================================== RCS file: /home/cvspublic/apr/threadproc/unix/signals.c,v retrieving revision 1.46 diff -u -r1.46 signals.c --- srclib/apr/threadproc/unix/signals.c 10 May 2002 03:56:44 -0000 1.46 +++ srclib/apr/threadproc/unix/signals.c 21 May 2002 14:53:40 -0000 @@ -87,6 +87,17 @@ #if APR_HAVE_SIGACTION +#ifdef DARWIN +static void avoid_zombies(int signo) +{ + int exit_status; + + while (waitpid(-1, &exit_status, WNOHANG) > 0) { + /* do nothing */ + } +} +#endif /* DARWIN */ + /* * Replace standard signal() with the more reliable sigaction equivalent * from W. Richard Stevens' "Advanced Programming in the UNIX Environment" @@ -110,6 +121,15 @@ */ if ((signo == SIGCHLD) && (func == SIG_IGN)) { act.sa_flags |= SA_NOCLDWAIT; + } +#endif +#ifdef DARWIN + /* ignoring SIGCHLD or leaving the default disposition doesn't avoid zombies, + * and there is no SA_NOCLDWAIT flag, so catch the signal and reap status in + * the handler to avoid zombies + */ + if ((signo == SIGCHLD) && (func == SIG_IGN)) { + act.sa_handler = avoid_zombies; } #endif if (sigaction(signo, &act, &oact) < 0) -- Jeff Trawick | trawick@attglobal.net Born in Roswell... married an alien...