trawick 02/05/22 04:15:29
Modified: . CHANGES
threadproc/unix signals.c
Log:
Darwin/Mac OS X: There is apparently no convenient way to keep deceased
children from waiting until the parent reaps status, so when the APR
app doesn't care about such status we need to have a handler driven
and call one of the wait functions.
PR: 9168
Revision Changes Path
1.290 +5 -0 apr/CHANGES
Index: CHANGES
===================================================================
RCS file: /home/cvs/apr/CHANGES,v
retrieving revision 1.289
retrieving revision 1.290
diff -u -r1.289 -r1.290
--- CHANGES 20 May 2002 13:43:57 -0000 1.289
+++ CHANGES 22 May 2002 11:15:29 -0000 1.290
@@ -1,4 +1,9 @@
Changes with APR b1
+
+ *) Darwin/Mac OS X: Don't leave zombie processes when the app calls
+ apr_signal(SIGCHLD, SIG_IGN). This fixes a problem with Apache's
+ mod_cgid. PR 9168. [Jeff Trawick]
+
*) Win32: Fix bug where apr_sendfile() was incorrectly returning
APR_SUCCESS on a TransmitFile call that was interrupted by
the client closing its end of the connection. Always call
1.47 +20 -0 apr/threadproc/unix/signals.c
Index: signals.c
===================================================================
RCS file: /home/cvs/apr/threadproc/unix/signals.c,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -r1.46 -r1.47
--- signals.c 10 May 2002 03:56:44 -0000 1.46
+++ signals.c 22 May 2002 11:15:29 -0000 1.47
@@ -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)