You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by Jeff Trawick <tr...@attglobal.net> on 2002/05/21 16:58:58 UTC
[PATCH] PR 9168 don't leave zombie processes on Mac OS X with mod_cgid
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...