You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by Kevin Pilch-Bisson <ke...@pilch-bisson.net> on 2001/09/21 15:26:47 UTC
[Patch] again
Here it is again with NULL checking.
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:26:18
@@ -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,24 @@
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)) {
+ if (exitcode != NULL) {
+ *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;