Here is a patch which makes the unix version of apr_proc_wait_all_procs a simple wrapper around apr_proc_wait, and which extracts the exit code from the status returned by waitpid.
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Kevin Pilch-Bisson http://www.pilch-bisson.net "Historically speaking, the presences of wheels in Unix has never precluded their reinvention." - Larry Wall ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Index: proc.c =================================================================== RCS file: /home/cvspublic/apr/threadproc/unix/proc.c,v retrieving revision 1.48 diff -u -r1.48 proc.c --- proc.c 2001/09/20 08:59:31 1.48 +++ proc.c 2001/09/21 13:04:21 @@ -364,19 +364,8 @@ APR_DECLARE(apr_status_t) apr_proc_wait_all_procs(apr_proc_t *proc, apr_wait_t *status, apr_wait_how_e waithow, apr_pool_t *p) { - int waitpid_options = WUNTRACED; - - if (waithow != APR_WAIT) { - waitpid_options |= WNOHANG; - } - - if ((proc->pid = waitpid(-1, status, waitpid_options)) > 0) { - return APR_CHILD_DONE; - } - else if (proc->pid == 0) { - return APR_CHILD_NOTDONE; - } - return errno; + proc->pid = -1; + return apr_proc_wait(proc, status, waithow); } APR_DECLARE(apr_status_t) apr_proc_wait(apr_proc_t *proc, @@ -384,18 +373,22 @@ apr_wait_how_e waithow) { pid_t pstatus; + int waitpid_options = WUNTRACED; + int exit_int; - if (waithow == APR_WAIT) { - if ((pstatus = waitpid(proc->pid, exitcode, WUNTRACED)) > 0) { - return APR_CHILD_DONE; + if (waithow != APR_WAIT) { + waitpid_options |= WNOHANG; + } + + if ((pstatus = waitpid(proc->pid, &exit_int, waitpid_options)) > 0) { + if (proc->pid == -1) { + proc->pid = pstatus; } - else if (pstatus == 0) { - return APR_CHILD_NOTDONE; + if (WIFEXITED(exit_int)) { + *exitcode = WEXITSTATUS(exit_int); + return APR_CHILD_DONE; } - return errno; - } - if ((pstatus = waitpid(proc->pid, exitcode, WUNTRACED | WNOHANG)) > 0) { - return APR_CHILD_DONE; + return APR_CHILD_NOTDONE; } else if (pstatus == 0) { return APR_CHILD_NOTDONE;
pgp9MD9xDRdyx.pgp
Description: PGP signature