Return-Path: Delivered-To: apmail-apr-cvs-archive@apr.apache.org Received: (qmail 98804 invoked by uid 500); 26 Oct 2001 02:39:15 -0000 Mailing-List: contact cvs-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Reply-To: dev@apr.apache.org Delivered-To: mailing list cvs@apr.apache.org Received: (qmail 98782 invoked from network); 26 Oct 2001 02:39:14 -0000 Date: 26 Oct 2001 02:31:04 -0000 Message-ID: <20011026023104.90756.qmail@icarus.apache.org> From: bjh@apache.org To: apr-cvs@apache.org Subject: cvs commit: apr/threadproc/os2 proc.c X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N bjh 01/10/25 19:31:04 Modified: threadproc/os2 proc.c Log: OS/2: Implement exitcode/exitwhy enhancements in apr_proc_wait* Revision Changes Path 1.47 +64 -8 apr/threadproc/os2/proc.c Index: proc.c =================================================================== RCS file: /home/cvs/apr/threadproc/os2/proc.c,v retrieving revision 1.46 retrieving revision 1.47 diff -u -r1.46 -r1.47 --- proc.c 2001/10/23 17:30:08 1.46 +++ proc.c 2001/10/26 02:31:04 1.47 @@ -496,6 +496,66 @@ 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 @@ 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 @@ 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;