summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbjh <bjh@13f79535-47bb-0310-9956-ffa450edef68>2001-10-26 02:31:04 +0000
committerbjh <bjh@13f79535-47bb-0310-9956-ffa450edef68>2001-10-26 02:31:04 +0000
commit2da874ef99f4fb55d068243f0196cc414065f6c9 (patch)
tree86479c9067ce04bb8784c785810e675b5f7d6bba
parent5c0939aa0c32ca10e3c3c90b29cde7a4fde324ab (diff)
downloadlibapr-2da874ef99f4fb55d068243f0196cc414065f6c9.tar.gz
OS/2: Implement exitcode/exitwhy enhancements in apr_proc_wait*
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@62464 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--threadproc/os2/proc.c72
1 files changed, 64 insertions, 8 deletions
diff --git a/threadproc/os2/proc.c b/threadproc/os2/proc.c
index 1195506a3..927fd96ec 100644
--- a/threadproc/os2/proc.c
+++ b/threadproc/os2/proc.c
@@ -496,6 +496,66 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *proc, const char *progname
return status;
}
+
+
+static void proces_result_codes(RESULTCODES codes,
+ int *exitcode,
+ apr_exit_why_e *exitwhy)
+{
+ int result = 0;
+ apr_exit_why_e why = APR_PROC_EXIT;
+
+ switch (codes.codeTerminate) {
+ case TC_EXIT: /* Normal exit */
+ why = APR_PROC_EXIT;
+ result = codes.codeResult;
+ break;
+
+ case TC_HARDERROR: /* Hard error halt */
+ why = APR_PROC_SIGNAL;
+ result = SIGSYS;
+ break;
+
+ case TC_KILLPROCESS: /* Was killed by a DosKillProcess() */
+ why = APR_PROC_SIGNAL;
+ result = SIGKILL;
+ break;
+
+ case TC_TRAP: /* TRAP in 16 bit code */
+ case TC_EXCEPTION: /* Threw an exception (32 bit code) */
+ why = APR_PROC_SIGNAL;
+
+ switch (codes.codeResult | XCPT_FATAL_EXCEPTION) {
+ case XCPT_ACCESS_VIOLATION:
+ result = SIGSEGV;
+ break;
+
+ case XCPT_ILLEGAL_INSTRUCTION:
+ result = SIGILL;
+ break;
+
+ case XCPT_FLOAT_DIVIDE_BY_ZERO:
+ case XCPT_INTEGER_DIVIDE_BY_ZERO:
+ result = SIGFPE;
+ break;
+
+ default:
+ result = codes.codeResult;
+ break;
+ }
+ }
+
+ if (exitcode) {
+ *exitcode = result;
+ }
+
+ if (exitwhy) {
+ *exitwhy = why;
+ }
+}
+
+
+
APR_DECLARE(apr_status_t) apr_proc_wait_all_procs(apr_proc_t *proc,
int *exitcode,
apr_exit_why_e *exitwhy,
@@ -509,14 +569,11 @@ APR_DECLARE(apr_status_t) apr_proc_wait_all_procs(apr_proc_t *proc,
if (!proc)
return APR_ENOPROC;
- rc = DosWaitChild(DCWA_PROCESSTREE, wait == APR_WAIT ? DCWW_WAIT : DCWW_NOWAIT, &codes, &pid, 0);
+ rc = DosWaitChild(DCWA_PROCESSTREE, waithow == APR_WAIT ? DCWW_WAIT : DCWW_NOWAIT, &codes, &pid, 0);
if (rc == 0) {
proc->pid = pid;
-
- if (status)
- *status = codes.codeResult;
-
+ proces_result_codes(codes, exitcode, exitwhy);
return APR_CHILD_DONE;
} else if (rc == ERROR_CHILD_NOT_COMPLETE) {
return APR_CHILD_NOTDONE;
@@ -538,11 +595,10 @@ APR_DECLARE(apr_status_t) apr_proc_wait(apr_proc_t *proc,
if (!proc)
return APR_ENOPROC;
- rc = DosWaitChild(DCWA_PROCESS, wait == APR_WAIT ? DCWW_WAIT : DCWW_NOWAIT, &codes, &pid, proc->pid);
+ rc = DosWaitChild(DCWA_PROCESS, waithow == APR_WAIT ? DCWW_WAIT : DCWW_NOWAIT, &codes, &pid, proc->pid);
- if (exitcode)
- *exitcode = codes.codeResult;
if (rc == 0) {
+ proces_result_codes(codes, exitcode, exitwhy);
return APR_CHILD_DONE;
} else if (rc == ERROR_CHILD_NOT_COMPLETE) {
return APR_CHILD_NOTDONE;