From f38434bbfe99d86978a95eecfcca459cf99ae2cb Mon Sep 17 00:00:00 2001 From: Jeff Trawick Date: Thu, 18 May 2000 02:17:24 +0000 Subject: Fix problem where the Unix mpms had an unitialized variable for child exit status by adding an exit status parameter to ap_wait_all_procs(); with this change, the mpms use ap_wait_all_procs() more like they previously used waitpid(). With the introduction of the exit status parameter, the definition of ap_wait_t was moved from Apache to APR. There was some handling of union wait for the type of the exit status parameter to waitpid() which I retained (but cannot test). For WIN32, ap_wait_t was defined as int (in apr.hw). No current Windows code uses ap_wait_t, but a type is required so that references to ap_wait_t in apr_thread_proc.h can compile on Windows. Note: There is still a storage leak in the way that the Unix mpms call ap_wait_all_procs()... this will be resolved at some later time. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@60064 13f79535-47bb-0310-9956-ffa450edef68 --- threadproc/unix/proc.c | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) (limited to 'threadproc/unix/proc.c') diff --git a/threadproc/unix/proc.c b/threadproc/unix/proc.c index 7f00b860d..e515e5d02 100644 --- a/threadproc/unix/proc.c +++ b/threadproc/unix/proc.c @@ -320,34 +320,25 @@ ap_status_t ap_get_childerr(ap_file_t **new, ap_proc_t *proc) return APR_SUCCESS; } -ap_status_t ap_wait_all_procs(ap_proc_t **proc, +ap_status_t ap_wait_all_procs(ap_proc_t **proc, ap_wait_t *status, ap_wait_how_e waithow, ap_pool_t *p) { - pid_t status; - if (waithow == APR_WAIT) { - if ((status = waitpid(-1, NULL, WUNTRACED)) > 0) { - if (!*proc) { - (*proc) = ap_pcalloc(p, sizeof(ap_proc_t)); - (*proc)->cntxt = p; - } - (*proc)->pid = status; - return APR_CHILD_DONE; - } - else if (status == 0) { - (*proc) = NULL; - return APR_CHILD_NOTDONE; - } - return errno; + pid_t pid; + int waitpid_options = WUNTRACED; + + if (waithow != APR_WAIT) { + waitpid_options |= WNOHANG; } - if ((status = waitpid(-1, NULL, WUNTRACED | WNOHANG)) > 0) { + + if ((pid = waitpid(-1, status, waitpid_options)) > 0) { if (!*proc) { (*proc) = ap_pcalloc(p, sizeof(ap_proc_t)); (*proc)->cntxt = p; } - (*proc)->pid = status; + (*proc)->pid = pid; return APR_CHILD_DONE; } - else if (status == 0) { + else if (pid == 0) { (*proc) = NULL; return APR_CHILD_NOTDONE; } -- cgit v1.2.3