aboutsummaryrefslogtreecommitdiff
path: root/threadproc/unix/proc.c
diff options
context:
space:
mode:
authorJeff Trawick <trawick@apache.org>2000-05-18 02:17:24 +0000
committerJeff Trawick <trawick@apache.org>2000-05-18 02:17:24 +0000
commitf38434bbfe99d86978a95eecfcca459cf99ae2cb (patch)
treefa6dcd6099f679274e94e67cc5f1a6f0463627d8 /threadproc/unix/proc.c
parentb23effac6c1a0df3e57c7d420bfd2957e9c238df (diff)
downloadapr-f38434bbfe99d86978a95eecfcca459cf99ae2cb.tar.gz
apr-f38434bbfe99d86978a95eecfcca459cf99ae2cb.zip
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
Diffstat (limited to 'threadproc/unix/proc.c')
-rw-r--r--threadproc/unix/proc.c29
1 files changed, 10 insertions, 19 deletions
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;
}