summaryrefslogtreecommitdiff
path: root/threadproc
diff options
context:
space:
mode:
authortrawick <trawick@13f79535-47bb-0310-9956-ffa450edef68>2002-05-22 11:15:29 +0000
committertrawick <trawick@13f79535-47bb-0310-9956-ffa450edef68>2002-05-22 11:15:29 +0000
commitdbd76b30e1c0239e5c25c495517982b9211e1efe (patch)
tree3a63aa4b766dedb907ff187fb1e53f2bb5181a60 /threadproc
parent6ba758ffab9343278fe872be6b64597d08177952 (diff)
downloadlibapr-dbd76b30e1c0239e5c25c495517982b9211e1efe.tar.gz
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 git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@63423 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'threadproc')
-rw-r--r--threadproc/unix/signals.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/threadproc/unix/signals.c b/threadproc/unix/signals.c
index 2affb84a2..5127868b9 100644
--- a/threadproc/unix/signals.c
+++ b/threadproc/unix/signals.c
@@ -87,6 +87,17 @@ APR_DECLARE(apr_status_t) apr_proc_kill(apr_proc_t *proc, int signum)
#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"
@@ -112,6 +123,15 @@ APR_DECLARE(apr_sigfunc_t *) apr_signal(int signo, apr_sigfunc_t * func)
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)
return SIG_ERR;
return oact.sa_handler;