diff options
author | gstein <gstein@13f79535-47bb-0310-9956-ffa450edef68> | 2001-09-20 08:59:31 +0000 |
---|---|---|
committer | gstein <gstein@13f79535-47bb-0310-9956-ffa450edef68> | 2001-09-20 08:59:31 +0000 |
commit | 8dbc1a060636ffbd82ba5b2a881662c4e79de1cf (patch) | |
tree | ff0d0e062cdca382a2e2f2d0c46fa69fc5090d6f /threadproc | |
parent | 0459d5dd7766c6b2428e8bb08ce8122b81edec55 (diff) | |
download | libapr-8dbc1a060636ffbd82ba5b2a881662c4e79de1cf.tar.gz |
Return the exit code from apr_proc_wait(). This is a combination of a patch
from Justin and Bill, plus a few additional tweaks.
Submitted by: Justin Erenkrantz <jerenkrantz@ebuilt.com>,
Bill Tutt <billtut@microsoft.com>
Reviewed by: Greg Stein
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@62350 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'threadproc')
-rw-r--r-- | threadproc/beos/proc.c | 5 | ||||
-rw-r--r-- | threadproc/netware/proc.c | 1 | ||||
-rw-r--r-- | threadproc/os2/proc.c | 3 | ||||
-rw-r--r-- | threadproc/unix/proc.c | 11 | ||||
-rw-r--r-- | threadproc/win32/proc.c | 28 |
5 files changed, 28 insertions, 20 deletions
diff --git a/threadproc/beos/proc.c b/threadproc/beos/proc.c index 4d527b42a..3f0476a76 100644 --- a/threadproc/beos/proc.c +++ b/threadproc/beos/proc.c @@ -299,16 +299,17 @@ APR_DECLARE(apr_status_t) apr_proc_wait_all_procs(apr_proc_t *proc, apr_wait_t * } APR_DECLARE(apr_status_t) apr_proc_wait(apr_proc_t *proc, + apr_wait_t *exitcode, apr_wait_how_e wait) { - status_t exitval, rv; + status_t rv; if (!proc) return APR_ENOPROC; /* when we run processes we are actually running threads, so here we'll wait on the thread dying... */ if (wait == APR_WAIT) { - if ((rv = wait_for_thread(proc->pid, &exitval)) == B_OK) { + if ((rv = wait_for_thread(proc->pid, exitcode)) == B_OK) { return APR_CHILD_DONE; } return rv; diff --git a/threadproc/netware/proc.c b/threadproc/netware/proc.c index 7124f8a17..a537f7651 100644 --- a/threadproc/netware/proc.c +++ b/threadproc/netware/proc.c @@ -393,6 +393,7 @@ apr_status_t apr_proc_wait_all_procs(apr_proc_t *proc, apr_wait_t *status, } apr_status_t apr_proc_wait(apr_proc_t *proc, + apr_wait_t *exitcode, apr_wait_how_e waithow) { #if 0 diff --git a/threadproc/os2/proc.c b/threadproc/os2/proc.c index f890986fb..f092e6716 100644 --- a/threadproc/os2/proc.c +++ b/threadproc/os2/proc.c @@ -527,6 +527,7 @@ APR_DECLARE(apr_status_t) apr_proc_wait_all_procs(apr_proc_t *proc, apr_wait_t * APR_DECLARE(apr_status_t) apr_proc_wait(apr_proc_t *proc, + apr_wait_t *exitcode, apr_wait_how_e wait) { RESULTCODES codes; @@ -538,6 +539,8 @@ APR_DECLARE(apr_status_t) apr_proc_wait(apr_proc_t *proc, rc = DosWaitChild(DCWA_PROCESS, wait == APR_WAIT ? DCWW_WAIT : DCWW_NOWAIT, &codes, &pid, proc->pid); + if (exitcode) + *exitcode = codes.codeResult; if (rc == 0) { return APR_CHILD_DONE; } else if (rc == ERROR_CHILD_NOT_COMPLETE) { diff --git a/threadproc/unix/proc.c b/threadproc/unix/proc.c index 41f8007c9..619b18d89 100644 --- a/threadproc/unix/proc.c +++ b/threadproc/unix/proc.c @@ -380,23 +380,24 @@ APR_DECLARE(apr_status_t) apr_proc_wait_all_procs(apr_proc_t *proc, apr_wait_t * } APR_DECLARE(apr_status_t) apr_proc_wait(apr_proc_t *proc, + apr_wait_t *exitcode, apr_wait_how_e waithow) { - pid_t status; + pid_t pstatus; if (waithow == APR_WAIT) { - if ((status = waitpid(proc->pid, NULL, WUNTRACED)) > 0) { + if ((pstatus = waitpid(proc->pid, exitcode, WUNTRACED)) > 0) { return APR_CHILD_DONE; } - else if (status == 0) { + else if (pstatus == 0) { return APR_CHILD_NOTDONE; } return errno; } - if ((status = waitpid(proc->pid, NULL, WUNTRACED | WNOHANG)) > 0) { + if ((pstatus = waitpid(proc->pid, exitcode, WUNTRACED | WNOHANG)) > 0) { return APR_CHILD_DONE; } - else if (status == 0) { + else if (pstatus == 0) { return APR_CHILD_NOTDONE; } return errno; diff --git a/threadproc/win32/proc.c b/threadproc/win32/proc.c index 8a7848228..c1b26f025 100644 --- a/threadproc/win32/proc.c +++ b/threadproc/win32/proc.c @@ -540,27 +540,29 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new, return APR_SUCCESS; } -APR_DECLARE(apr_status_t) apr_proc_wait(apr_proc_t *proc, apr_wait_how_e wait) +APR_DECLARE(apr_status_t) apr_proc_wait(apr_proc_t *proc, + apr_wait_t *exitcode, + apr_wait_how_e wait) { DWORD stat; + DWORD time; + if (!proc) return APR_ENOPROC; - if (wait == APR_WAIT) { - if ((stat = WaitForSingleObject(proc->hproc, - INFINITE)) == WAIT_OBJECT_0) { + + if (wait == APR_WAIT) + time = INFINITE; + else + time = 0; + + if ((stat = WaitForSingleObject(proc->hproc, time)) == WAIT_OBJECT_0) { + if (GetExitCodeProcess((HANDLE)proc->pid, &stat)) { + if (exitcode) + *exitcode = (apr_wait_t)stat; CloseHandle(proc->hproc); proc->hproc = NULL; return APR_CHILD_DONE; } - else if (stat == WAIT_TIMEOUT) { - return APR_CHILD_NOTDONE; - } - return apr_get_os_error(); - } - if ((stat = WaitForSingleObject((HANDLE)proc->hproc, 0)) == WAIT_OBJECT_0) { - CloseHandle(proc->hproc); - proc->hproc = NULL; - return APR_CHILD_DONE; } else if (stat == WAIT_TIMEOUT) { return APR_CHILD_NOTDONE; |