gstein 01/09/20 01:59:31
Modified: include apr_thread_proc.h
threadproc/beos proc.c
threadproc/netware proc.c
threadproc/os2 proc.c
threadproc/unix proc.c
threadproc/win32 proc.c
Log:
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 <[EMAIL PROTECTED]>,
Bill Tutt <[EMAIL PROTECTED]>
Reviewed by: Greg Stein
Revision Changes Path
1.75 +6 -0 apr/include/apr_thread_proc.h
Index: apr_thread_proc.h
===================================================================
RCS file: /home/cvs/apr/include/apr_thread_proc.h,v
retrieving revision 1.74
retrieving revision 1.75
diff -u -r1.74 -r1.75
--- apr_thread_proc.h 2001/09/09 06:03:05 1.74
+++ apr_thread_proc.h 2001/09/20 08:59:30 1.75
@@ -481,6 +481,11 @@
/**
* Wait for a child process to die
* @param proc The process handle that corresponds to the desired child
process
+ * @param exitcode The returned exit status of the child, if a child process
+ * dies. On platforms that don't support obtaining this
+ * information, the exitcode parameter will be returned as
+ * APR_ENOTIMPL. This parameter may be NULL if the exit code
+ * is not needed.
* @param waithow How should we wait. One of:
* <PRE>
* APR_WAIT -- block until the child process dies.
@@ -494,6 +499,7 @@
* </PRE>
*/
APR_DECLARE(apr_status_t) apr_proc_wait(apr_proc_t *proc,
+ apr_wait_t *exitcode,
apr_wait_how_e waithow);
/**
1.40 +3 -2 apr/threadproc/beos/proc.c
Index: proc.c
===================================================================
RCS file: /home/cvs/apr/threadproc/beos/proc.c,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -r1.39 -r1.40
--- proc.c 2001/09/11 13:33:39 1.39
+++ proc.c 2001/09/20 08:59:30 1.40
@@ -299,16 +299,17 @@
}
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;
1.2 +1 -0 apr/threadproc/netware/proc.c
Index: proc.c
===================================================================
RCS file: /home/cvs/apr/threadproc/netware/proc.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- proc.c 2001/08/02 20:29:14 1.1
+++ proc.c 2001/09/20 08:59:30 1.2
@@ -393,6 +393,7 @@
}
apr_status_t apr_proc_wait(apr_proc_t *proc,
+ apr_wait_t *exitcode,
apr_wait_how_e waithow)
{
#if 0
1.45 +3 -0 apr/threadproc/os2/proc.c
Index: proc.c
===================================================================
RCS file: /home/cvs/apr/threadproc/os2/proc.c,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -r1.44 -r1.45
--- proc.c 2001/08/23 16:42:27 1.44
+++ proc.c 2001/09/20 08:59:30 1.45
@@ -527,6 +527,7 @@
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 @@
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) {
1.48 +6 -5 apr/threadproc/unix/proc.c
Index: proc.c
===================================================================
RCS file: /home/cvs/apr/threadproc/unix/proc.c,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -r1.47 -r1.48
--- proc.c 2001/08/10 21:04:48 1.47
+++ proc.c 2001/09/20 08:59:31 1.48
@@ -380,23 +380,24 @@
}
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;
1.56 +15 -13 apr/threadproc/win32/proc.c
Index: proc.c
===================================================================
RCS file: /home/cvs/apr/threadproc/win32/proc.c,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -r1.55 -r1.56
--- proc.c 2001/09/17 21:24:29 1.55
+++ proc.c 2001/09/20 08:59:31 1.56
@@ -540,27 +540,29 @@
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;