apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ryan Bloom <...@covalent.net>
Subject [PATCH] apr_proc_wait
Date Mon, 22 Oct 2001 18:24:26 GMT

This patch implements my idea for a new API to apr_proc_wait and 
apr_proc_all_wait.  This includes the changes to Apache as well as the changes
to APR.  The basic concept is that we return the reason for exiting and the
exit code.  If the child was sent a signal and died because of that, the exit
code is the signal that the process received.  The other part of this, is that APR
now has macros that determine if the process has generated a core dump.  If
we want to add more macros to this, we can easily extend it.  This patch
also removes all instances of the W* macros from Apache.

I took the basic idea from Jeff Trawick's patches.

Ryan

Index: include/mpm_common.h
===================================================================
RCS file: /home/cvs/httpd-2.0/include/mpm_common.h,v
retrieving revision 1.28
diff -u -d -b -w -u -r1.28 mpm_common.h
--- include/mpm_common.h	2001/08/14 12:30:49	1.28
+++ include/mpm_common.h	2001/10/22 17:56:16
@@ -125,7 +125,8 @@
  * @param p The pool to allocate out of
  */
 #ifdef AP_MPM_WANT_WAIT_OR_TIMEOUT
-void ap_wait_or_timeout(apr_wait_t *status, apr_proc_t *ret, apr_pool_t *p);
+void ap_wait_or_timeout(apr_exit_why_e *status, int *exitcode, apr_proc_t *ret, 
+                        apr_pool_t *p);
 #endif
 
 /**
@@ -135,7 +136,7 @@
  * @param status The status returned from ap_wait_or_timeout
  */
 #ifdef AP_MPM_WANT_PROCESS_CHILD_STATUS
-void ap_process_child_status(apr_proc_t *pid, apr_wait_t status);
+void ap_process_child_status(apr_proc_t *pid, apr_exit_why_e why, int status);
 #endif
 
 #if defined(TCP_NODELAY) && !defined(MPE) && !defined(TPF)
Index: server/mpm_common.c
===================================================================
RCS file: /home/cvs/httpd-2.0/server/mpm_common.c,v
retrieving revision 1.69
diff -u -d -b -w -u -r1.69 mpm_common.c
--- server/mpm_common.c	2001/09/21 14:29:33	1.69
+++ server/mpm_common.c	2001/10/22 17:56:16
@@ -124,7 +124,7 @@
                 continue;
 
             proc.pid = pid;
-            waitret = apr_proc_wait(&proc, NULL, APR_NOWAIT);
+            waitret = apr_proc_wait(&proc, NULL, NULL, APR_NOWAIT);
             if (waitret != APR_CHILD_NOTDONE) {
                 MPM_NOTE_CHILD_KILLED(i);
                 continue;
@@ -196,7 +196,8 @@
 #endif
 static int wait_or_timeout_counter;
 
-void ap_wait_or_timeout(apr_wait_t *status, apr_proc_t *ret, apr_pool_t *p)
+void ap_wait_or_timeout(apr_exit_why_e *status, int *exitcode, apr_proc_t *ret,
+                        apr_pool_t *p)
 {
     apr_status_t rv;
 
@@ -204,7 +205,7 @@
     if (wait_or_timeout_counter == INTERVAL_OF_WRITABLE_PROBES) {
         wait_or_timeout_counter = 0;
     }
-    rv = apr_proc_wait_all_procs(ret, status, APR_NOWAIT, p);
+    rv = apr_proc_wait_all_procs(ret, exitcode, status, APR_NOWAIT, p);
     if (APR_STATUS_IS_EINTR(rv)) {
         ret->pid = -1;
         return;
@@ -213,7 +214,7 @@
         return;
     }
 #ifdef NEED_WAITPID
-    if ((ret = reap_children(status)) > 0) {
+    if ((ret = reap_children(exitcode, status)) > 0) {
         return;
     }
 #endif
@@ -224,16 +225,16 @@
 #endif /* AP_MPM_WANT_WAIT_OR_TIMEOUT */
 
 #ifdef AP_MPM_WANT_PROCESS_CHILD_STATUS
-void ap_process_child_status(apr_proc_t *pid, apr_wait_t status)
+void ap_process_child_status(apr_proc_t *pid, apr_exit_why_e why, int status)
 {
-    int signum = WTERMSIG(status);
+    int signum = status;
     const char *sigdesc = apr_signal_get_description(signum);
 
     /* Child died... if it died due to a fatal error,
         * we should simply bail out.
         */
-    if ((WIFEXITED(status)) &&
-        WEXITSTATUS(status) == APEXIT_CHILDFATAL) {
+    if ((APR_PROC_CHECK_EXIT(why)) &&
+        (status == APEXIT_CHILDFATAL)) {
         ap_log_error(APLOG_MARK, APLOG_ALERT|APLOG_NOERRNO, 0, ap_server_conf,
                         "Child %ld returned a Fatal error..." APR_EOL_STR
                         "Apache is exiting!",
@@ -241,7 +242,7 @@
         exit(APEXIT_CHILDFATAL);
     }
 
-    if (WIFSIGNALED(status)) {
+    if (APR_PROC_CHECK_SIGNALED(why)) {
         switch (signum) {
         case SIGTERM:
         case SIGHUP:
@@ -249,8 +250,7 @@
         case SIGKILL:
             break;
         default:
-#ifdef WCOREDUMP
-            if (WCOREDUMP(status)) {
+            if (APR_PROC_CHECK_CORE_DUMP(why)) {
                 ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE,
                              0, ap_server_conf,
                              "child pid %ld exit signal %s (%d), "
@@ -258,9 +258,7 @@
                              (long)pid->pid, sigdesc, signum,
                              ap_coredump_dir);
             }
-            else
-#endif
-            {
+            else {
                 ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE,
                              0, ap_server_conf,
                              "child pid %ld exit signal %s (%d)",
Index: server/mpm/beos/beos.c
===================================================================
RCS file: /home/cvs/httpd-2.0/server/mpm/beos/beos.c,v
retrieving revision 1.62
diff -u -d -b -w -u -r1.62 beos.c
--- server/mpm/beos/beos.c	2001/09/18 22:13:58	1.62
+++ server/mpm/beos/beos.c	2001/10/22 17:56:16
@@ -597,16 +597,17 @@
 static void server_main_loop(int remaining_threads_to_start)
 {
     int child_slot;
-    apr_wait_t status;
+    apr_exit_why_e exitwhy;
+    int status;
     apr_proc_t pid;
     int i;
 
     while (!restart_pending && !shutdown_pending) {
 
-        ap_wait_or_timeout(&status, &pid, pconf);
+        ap_wait_or_timeout(&exitwhy, &status, &pid, pconf);
          
         if (pid.pid >= 0) {
-            ap_process_child_status(&pid, status);
+            ap_process_child_status(&pid, exitwhy, status);
             /* non-fatal death... note that it's gone in the scoreboard. */
             child_slot = -1;
             for (i = 0; i < ap_max_child_assigned; ++i) {
Index: server/mpm/perchild/perchild.c
===================================================================
RCS file: /home/cvs/httpd-2.0/server/mpm/perchild/perchild.c,v
retrieving revision 1.79
diff -u -d -b -w -u -r1.79 perchild.c
--- server/mpm/perchild/perchild.c	2001/09/18 22:13:58	1.79
+++ server/mpm/perchild/perchild.c	2001/10/22 17:56:16
@@ -1091,15 +1091,16 @@
 static void server_main_loop(int remaining_children_to_start)
 {
     int child_slot;
-    apr_wait_t status;
+    apr_exit_why exitwhy;
+    int status;
     apr_proc_t pid;
     int i;
 
     while (!restart_pending && !shutdown_pending) {
-        ap_wait_or_timeout(&status, &pid, pconf);
+        ap_wait_or_timeout(&exitwhy, &status, &pid, pconf);
         
         if (pid.pid != -1) {
-            ap_process_child_status(&pid, status);
+            ap_process_child_status(&pid, exitwhy, status);
             /* non-fatal death... note that it's gone in the child table and
              * clean out the status table. */
             child_slot = -1;
Index: server/mpm/prefork/prefork.c
===================================================================
RCS file: /home/cvs/httpd-2.0/server/mpm/prefork/prefork.c,v
retrieving revision 1.204
diff -u -d -b -w -u -r1.204 prefork.c
--- server/mpm/prefork/prefork.c	2001/10/16 18:45:16	1.204
+++ server/mpm/prefork/prefork.c	2001/10/22 17:56:16
@@ -369,7 +369,7 @@
    Systems without a real waitpid sometimes lose a child's exit while waiting
    for another.  Search through the scoreboard for missing children.
  */
-int reap_children(apr_wait_t *status)
+int reap_children(int *exitcode, apr_exit_why_e *status)
 {
     int n, pid;
 
@@ -379,7 +379,8 @@
 		kill((pid = ap_scoreboard_image->parent[n].pid), 0) == -1) {
 	    ap_update_child_status(AP_CHILD_THREAD_FROM_ID(n), SERVER_DEAD, NULL);
 	    /* just mark it as having a successful exit status */
-	    memset(status, 0, sizeof(apr_wait_t));
+            *status = APR_PROC_EXIT;
+            *exitcode = 0;
 	    return(pid);
 	}
     }
@@ -1171,18 +1172,19 @@
 
     while (!restart_pending && !shutdown_pending) {
 	int child_slot;
-	apr_wait_t status;
+        apr_exit_why_e exitwhy;
+	int status;
         /* this is a memory leak, but I'll fix it later. */
 	apr_proc_t pid;
 
-        ap_wait_or_timeout(&status, &pid, pconf);
+        ap_wait_or_timeout(&exitwhy, &status, &pid, pconf);
 
 	/* XXX: if it takes longer than 1 second for all our children
 	 * to start up and get into IDLE state then we may spawn an
 	 * extra child
 	 */
 	if (pid.pid != -1) {
-	    ap_process_child_status(&pid, status);
+	    ap_process_child_status(&pid, exitwhy, status);
 	    /* non-fatal death... note that it's gone in the scoreboard. */
 	    ap_sync_scoreboard_image();
 	    child_slot = find_child_by_pid(&pid);
Index: server/mpm/threaded/threaded.c
===================================================================
RCS file: /home/cvs/httpd-2.0/server/mpm/threaded/threaded.c,v
retrieving revision 1.65
diff -u -d -b -w -u -r1.65 threaded.c
--- server/mpm/threaded/threaded.c	2001/10/16 04:02:28	1.65
+++ server/mpm/threaded/threaded.c	2001/10/22 17:56:17
@@ -1122,15 +1122,16 @@
 static void server_main_loop(int remaining_children_to_start)
 {
     int child_slot;
-    apr_wait_t status;
+    apr_exit_why_e exitwhy;
+    int status;
     apr_proc_t pid;
     int i;
 
     while (!restart_pending && !shutdown_pending) {
-        ap_wait_or_timeout(&status, &pid, pconf);
+        ap_wait_or_timeout(&exitwhy, &status, &pid, pconf);
         
         if (pid.pid != -1) {
-            ap_process_child_status(&pid, status);
+            ap_process_child_status(&pid, exitwhy, status);
             /* non-fatal death... note that it's gone in the scoreboard. */
             child_slot = find_child_by_pid(&pid);
             if (child_slot >= 0) {
Index: server/mpm/worker/worker.c
===================================================================
RCS file: /home/cvs/httpd-2.0/server/mpm/worker/worker.c,v
retrieving revision 1.30
diff -u -d -b -w -u -r1.30 worker.c
--- server/mpm/worker/worker.c	2001/10/19 23:45:39	1.30
+++ server/mpm/worker/worker.c	2001/10/22 17:56:18
@@ -1187,15 +1187,16 @@
 static void server_main_loop(int remaining_children_to_start)
 {
     int child_slot;
-    apr_wait_t status;
+    apr_exit_why_e exitwhy;
+    int status;
     apr_proc_t pid;
     int i;
 
     while (!restart_pending && !shutdown_pending) {
-        ap_wait_or_timeout(&status, &pid, pconf);
+        ap_wait_or_timeout(&exitwhy, &status, &pid, pconf);
         
         if (pid.pid != -1) {
-            ap_process_child_status(&pid, status);
+            ap_process_child_status(&pid, exitwhy, status);
             /* non-fatal death... note that it's gone in the scoreboard. */
             child_slot = find_child_by_pid(&pid);
             if (child_slot >= 0) {
Index: srclib/apr/include/apr_thread_proc.h
===================================================================
RCS file: /home/cvs/apr/include/apr_thread_proc.h,v
retrieving revision 1.75
diff -u -d -b -w -u -r1.75 apr_thread_proc.h
--- srclib/apr/include/apr_thread_proc.h	2001/09/20 08:59:30	1.75
+++ srclib/apr/include/apr_thread_proc.h	2001/10/22 17:56:20
@@ -81,6 +81,17 @@
 
 typedef enum {APR_SHELLCMD, APR_PROGRAM} apr_cmdtype_e;
 typedef enum {APR_WAIT, APR_NOWAIT} apr_wait_how_e;
+/* I am specifically calling out the values so that the macros below make
+ * more sense.  Yes, I know I don't need to, but I am hoping this makes what
+ * I am doing more clear.  If you want to add more reasons to exit, continue
+ * to use bitmasks.
+ */
+typedef enum {APR_PROC_EXIT = 1, APR_PROC_SIGNAL = 2, 
+              APR_PROC_SIGNAL_CORE = 4} apr_exit_why_e;
+
+#define APR_PROC_CHECK_EXIT(x)        (x & APR_PROC_EXIT)
+#define APR_PROC_CHECK_SIGNALED(x)    (x & APR_PROC_SIGNAL)
+#define APR_PROC_CHECK_CORE_DUMP(x)   (x & APR_PROC_SIGNAL_CORE)
 
 #define APR_NO_PIPE          0
 #define APR_FULL_BLOCK       1
@@ -482,10 +493,16 @@
  * 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.
+ *                 dies, or the signal that caused the child to die.
+ *                 On platforms that don't support obtaining this information, 
+ *                 the status parameter will be returned as APR_ENOTIMPL.
+ * @param exitwhy Why the child died, the bitwise or of:
+ * <PRE>
+ *            APR_PROC_EXIT         -- process terminated normally
+ *            APR_PROC_SIGNAL       -- process was killed by a signal
+ *            APR_PROC_SIGNAL_CORE  -- process was killed by a signal, and
+ *                                     generated a core dump.
+ * </PRE>
  * @param waithow How should we wait.  One of:
  * <PRE>
  *            APR_WAIT   -- block until the child process dies.
@@ -499,7 +516,7 @@
  * </PRE>
  */
 APR_DECLARE(apr_status_t) apr_proc_wait(apr_proc_t *proc, 
-                                        apr_wait_t *exitcode,
+                                        int *exitcode, apr_exit_why_e *exitwhy,
                                         apr_wait_how_e waithow);
 
 /**
@@ -507,9 +524,17 @@
  * about that child.
  * @param proc Pointer to NULL on entry, will be filled out with child's 
  *             information 
- * @param status The returned exit status of the child, if a child process dies
+ * @param exitcode The returned exit status of the child, if a child process 
+ *                 dies, or the signal that caused the child to die.
  *               On platforms that don't support obtaining this information, 
  *               the status parameter will be returned as APR_ENOTIMPL.
+ * @param exitwhy Why the child died, the bitwise or of:
+ * <PRE>
+ *            APR_PROC_EXIT         -- process terminated normally
+ *            APR_PROC_SIGNAL       -- process was killed by a signal
+ *            APR_PROC_SIGNAL_CORE  -- process was killed by a signal, and
+ *                                     generated a core dump.
+ * </PRE>
  * @param waithow How should we wait.  One of:
  * <PRE>
  *            APR_WAIT   -- block until the child process dies.
@@ -519,7 +544,8 @@
  * @param p Pool to allocate child information out of.
  */
 APR_DECLARE(apr_status_t) apr_proc_wait_all_procs(apr_proc_t *proc,
-                                             apr_wait_t *status,
+                                                  int *exitcode,
+                                                  apr_exit_why_e *exitwhy,
                                              apr_wait_how_e waithow,
                                              apr_pool_t *p);
 
Index: srclib/apr/memory/unix/apr_pools.c
===================================================================
RCS file: /home/cvs/apr/memory/unix/apr_pools.c,v
retrieving revision 1.113
diff -u -d -b -w -u -r1.113 apr_pools.c
--- srclib/apr/memory/unix/apr_pools.c	2001/09/28 15:22:35	1.113
+++ srclib/apr/memory/unix/apr_pools.c	2001/10/22 17:56:20
@@ -1505,7 +1505,7 @@
 #ifndef NEED_WAITPID
     /* Pick up all defunct processes */
     for (p = procs; p; p = p->next) {
-        if (apr_proc_wait(p->pid, NULL, APR_NOWAIT) != APR_CHILD_NOTDONE) {
+        if (apr_proc_wait(p->pid, NULL, NULL, APR_NOWAIT) != APR_CHILD_NOTDONE) {
             p->kill_how = kill_never;
         }
     }
@@ -1550,7 +1550,7 @@
     /* Now wait for all the signaled processes to die */
     for (p = procs; p; p = p->next) {
 	if (p->kill_how != kill_never) {
-	    (void) apr_proc_wait(p->pid, NULL, APR_WAIT);
+	    (void) apr_proc_wait(p->pid, NULL, NULL, APR_WAIT);
 	}
     }
 #ifdef WIN32
Index: srclib/apr/test/testproc.c
===================================================================
RCS file: /home/cvs/apr/test/testproc.c,v
retrieving revision 1.32
diff -u -d -b -w -u -r1.32 testproc.c
--- srclib/apr/test/testproc.c	2001/09/20 09:03:24	1.32
+++ srclib/apr/test/testproc.c	2001/10/22 17:56:20
@@ -142,7 +142,7 @@
     else printf( "Read failed.\n");
 
     TEST_NEQ("Waiting for child to die",
-             apr_proc_wait(&newproc, NULL, APR_WAIT),
+             apr_proc_wait(&newproc, NULL, NULL, APR_WAIT),
              APR_CHILD_DONE, "OK", "Failed")   
     STD_TEST_NEQ("Removing directory", apr_dir_remove("proctest", pool))
 
Index: srclib/apr/test/testprocmutex.c
===================================================================
RCS file: /home/cvs/apr/test/testprocmutex.c,v
retrieving revision 1.4
diff -u -d -b -w -u -r1.4 testprocmutex.c
--- srclib/apr/test/testprocmutex.c	2001/09/24 05:37:28	1.4
+++ srclib/apr/test/testprocmutex.c	2001/10/22 17:56:20
@@ -126,10 +126,10 @@
     printf("OK\n");
  
     printf("%-60s", "    Waiting for processes to exit");
-    s1 = apr_proc_wait(p1, NULL, APR_WAIT);
-    s2 = apr_proc_wait(p2, NULL, APR_WAIT);
-    s3 = apr_proc_wait(p3, NULL, APR_WAIT);
-    s4 = apr_proc_wait(p4, NULL, APR_WAIT);
+    s1 = apr_proc_wait(p1, NULL, NULL, APR_WAIT);
+    s2 = apr_proc_wait(p2, NULL, NULL, APR_WAIT);
+    s3 = apr_proc_wait(p3, NULL, NULL, APR_WAIT);
+    s4 = apr_proc_wait(p4, NULL, NULL, APR_WAIT);
     printf("OK\n");
  
     if ((*x) != MAX_COUNTER) {
Index: srclib/apr/test/testsock.c
===================================================================
RCS file: /home/cvs/apr/test/testsock.c,v
retrieving revision 1.23
diff -u -d -b -w -u -r1.23 testsock.c
--- srclib/apr/test/testsock.c	2001/09/20 09:03:24	1.23
+++ srclib/apr/test/testsock.c	2001/10/22 17:56:20
@@ -96,18 +96,18 @@
         exit(-1);
     }
 
-    while ((s1 = apr_proc_wait(&proc1, NULL, APR_NOWAIT)) == APR_CHILD_NOTDONE &&

-           (s2 = apr_proc_wait(&proc2, NULL, APR_NOWAIT)) == APR_CHILD_NOTDONE) {
+    while ((s1 = apr_proc_wait(&proc1, NULL, NULL, APR_NOWAIT)) == APR_CHILD_NOTDONE
&& 
+           (s2 = apr_proc_wait(&proc2, NULL, NULL, APR_NOWAIT)) == APR_CHILD_NOTDONE)
{
         continue;
     }
 
     if (s1 == APR_SUCCESS) {
         apr_proc_kill(&proc2, SIGTERM);
-        while (apr_proc_wait(&proc2, NULL, APR_WAIT) == APR_CHILD_NOTDONE);
+        while (apr_proc_wait(&proc2, NULL, NULL, APR_WAIT) == APR_CHILD_NOTDONE);
     }
     else {
         apr_proc_kill(&proc1, SIGTERM);
-        while (apr_proc_wait(&proc1, NULL, APR_WAIT) == APR_CHILD_NOTDONE);
+        while (apr_proc_wait(&proc1, NULL, NULL, APR_WAIT) == APR_CHILD_NOTDONE);
     }
     fprintf(stdout, "Network test completed.\n");   
 
@@ -163,18 +163,18 @@
         exit(-1);
     }
 
-    while ((s1 = apr_proc_wait(&proc1, NULL, APR_NOWAIT)) == APR_CHILD_NOTDONE &&

-           (s2 = apr_proc_wait(&proc2, NULL, APR_NOWAIT)) == APR_CHILD_NOTDONE) {
+    while ((s1 = apr_proc_wait(&proc1, NULL, NULL, APR_NOWAIT)) == APR_CHILD_NOTDONE
&& 
+           (s2 = apr_proc_wait(&proc2, NULL, NULL, APR_NOWAIT)) == APR_CHILD_NOTDONE)
{
         continue;
     }
 
     if (s1 == APR_SUCCESS) {
         apr_proc_kill(&proc2, SIGTERM);
-        while (apr_proc_wait(&proc2, NULL, APR_WAIT) == APR_CHILD_NOTDONE);
+        while (apr_proc_wait(&proc2, NULL, NULL, APR_WAIT) == APR_CHILD_NOTDONE);
     }
     else {
         apr_proc_kill(&proc1, SIGTERM);
-        while (apr_proc_wait(&proc1, NULL, APR_WAIT) == APR_CHILD_NOTDONE);
+        while (apr_proc_wait(&proc1, NULL, NULL, APR_WAIT) == APR_CHILD_NOTDONE);
     }
     fprintf(stdout, "Network test completed.\n");   
 
Index: srclib/apr/threadproc/beos/proc.c
===================================================================
RCS file: /home/cvs/apr/threadproc/beos/proc.c,v
retrieving revision 1.40
diff -u -d -b -w -u -r1.40 proc.c
--- srclib/apr/threadproc/beos/proc.c	2001/09/20 08:59:30	1.40
+++ srclib/apr/threadproc/beos/proc.c	2001/10/22 17:56:20
@@ -280,7 +280,9 @@
     return APR_SUCCESS;
 }
 
-APR_DECLARE(apr_status_t) apr_proc_wait_all_procs(apr_proc_t *proc, apr_wait_t *status,
+APR_DECLARE(apr_status_t) apr_proc_wait_all_procs(apr_proc_t *proc,
+                                                  int *exitcode,
+                                                  apr_exit_why_e *exitwhy,
                                           apr_wait_how_e waithow, apr_pool_t *p)
 {
     int waitpid_options = WUNTRACED;
@@ -299,8 +301,8 @@
 } 
 
 APR_DECLARE(apr_status_t) apr_proc_wait(apr_proc_t *proc, 
-                                        apr_wait_t *exitcode,
-                                        apr_wait_how_e wait)
+                                        int *exitcode, apr_exit_why_e *exitwhy,
+                                        apr_wait_how_e waithow)
 {
     status_t rv;
 
Index: srclib/apr/threadproc/netware/proc.c
===================================================================
RCS file: /home/cvs/apr/threadproc/netware/proc.c,v
retrieving revision 1.2
diff -u -d -b -w -u -r1.2 proc.c
--- srclib/apr/threadproc/netware/proc.c	2001/09/20 08:59:30	1.2
+++ srclib/apr/threadproc/netware/proc.c	2001/10/22 17:56:20
@@ -372,8 +372,11 @@
     return APR_SUCCESS;
 }
 
-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)
+APR_DECLARE(apr_status_t) apr_proc_wait_all_procs(apr_proc_t *proc,
+                                                  int *exitcode,
+                                                  apr_exit_why_e *exitwhy,
+                                                  apr_wait_how_e waithow,
+                                                  apr_pool_t *p)
 {
 #if 0
     int waitpid_options = WUNTRACED;
@@ -392,8 +395,8 @@
     return errno;
 } 
 
-apr_status_t apr_proc_wait(apr_proc_t *proc, 
-                           apr_wait_t *exitcode,
+APR_DECLARE(apr_status_t) apr_proc_wait(apr_proc_t *proc,
+                                        int *exitcode, apr_exit_why_e *exitwhy,
                            apr_wait_how_e waithow)
 {
 #if 0
Index: srclib/apr/threadproc/os2/proc.c
===================================================================
RCS file: /home/cvs/apr/threadproc/os2/proc.c,v
retrieving revision 1.45
diff -u -d -b -w -u -r1.45 proc.c
--- srclib/apr/threadproc/os2/proc.c	2001/09/20 08:59:30	1.45
+++ srclib/apr/threadproc/os2/proc.c	2001/10/22 17:56:22
@@ -496,10 +496,11 @@
     return status;
 }
 
-
-
-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)
+APR_DECLARE(apr_status_t) apr_proc_wait_all_procs(apr_proc_t *proc,
+                                                  int *exitcode,
+                                                  apr_exit_why_e *exitwhy,
+                                                  apr_wait_how_e waithow,
+                                                  apr_pool_t *p)
 {
     RESULTCODES codes;
     ULONG rc;
@@ -527,8 +528,8 @@
 
 
 APR_DECLARE(apr_status_t) apr_proc_wait(apr_proc_t *proc,
-                                        apr_wait_t *exitcode,
-                                        apr_wait_how_e wait)
+                                        int *exitcode, apr_exit_why_e *exitwhy,
+                                        apr_wait_how_e waithow)
 {
     RESULTCODES codes;
     ULONG rc;
Index: srclib/apr/threadproc/unix/proc.c
===================================================================
RCS file: /home/cvs/apr/threadproc/unix/proc.c,v
retrieving revision 1.49
diff -u -d -b -w -u -r1.49 proc.c
--- srclib/apr/threadproc/unix/proc.c	2001/09/21 16:14:50	1.49
+++ srclib/apr/threadproc/unix/proc.c	2001/10/22 17:56:22
@@ -362,37 +362,56 @@
 }
 
 APR_DECLARE(apr_status_t) apr_proc_wait_all_procs(apr_proc_t *proc, 
-                                                  apr_wait_t *status,
+                                                  int *exitcode,
+                                                  apr_exit_why_e *exitwhy,
                                                   apr_wait_how_e waithow, 
                                                   apr_pool_t *p)
 {
     proc->pid = -1;
-    return apr_proc_wait(proc, status, waithow);
+    return apr_proc_wait(proc, exitcode, exitwhy, waithow);
 } 
 
 APR_DECLARE(apr_status_t) apr_proc_wait(apr_proc_t *proc, 
-                                        apr_wait_t *exitcode,
+                                        int *exitcode, apr_exit_why_e *exitwhy,
                                         apr_wait_how_e waithow)
 {
     pid_t pstatus;
     int waitpid_options = WUNTRACED;
     int exit_int;
+    int ignore;
+    apr_exit_why_e ignorewhy;
 
+    if (exitcode == NULL) {
+        exitcode = &ignore;
+    }
+    if (exitwhy == NULL) {
+        exitwhy = &ignorewhy;
+    }
+
     if (waithow != APR_WAIT) {
         waitpid_options |= WNOHANG;
     }
     
     if ((pstatus = waitpid(proc->pid, &exit_int, waitpid_options)) > 0) {
-        if (proc->pid == -1) {
             proc->pid = pstatus;
-        }
         if (WIFEXITED(exit_int)) {
-            if (exitcode != NULL) {
+            *exitwhy = APR_PROC_EXIT;
                 *exitcode = WEXITSTATUS(exit_int);
             }
-            return APR_CHILD_DONE;
+        else if (WIFSIGNALED(exit_int)) {
+            *exitwhy = APR_PROC_SIGNAL;
+#ifdef WCOREDUMP
+            if (WCOREDUMP(exit_int)) {
+                *exitwhy |= APR_PROC_SIGNAL_CORE;
         }
-        return APR_CHILD_NOTDONE;
+#endif
+            *exitcode = WTERMSIG(exit_int);
+        }
+        else {
+            /* unexpected condition */
+            return APR_EGENERAL;
+        }
+        return APR_CHILD_DONE;
     }
     else if (pstatus == 0) {
         return APR_CHILD_NOTDONE;
Index: srclib/apr/threadproc/win32/proc.c
===================================================================
RCS file: /home/cvs/apr/threadproc/win32/proc.c,v
retrieving revision 1.57
diff -u -d -b -w -u -r1.57 proc.c
--- srclib/apr/threadproc/win32/proc.c	2001/09/20 17:21:01	1.57
+++ srclib/apr/threadproc/win32/proc.c	2001/10/22 17:56:22
@@ -541,8 +541,8 @@
 }
 
 APR_DECLARE(apr_status_t) apr_proc_wait(apr_proc_t *proc,
-                                        apr_wait_t *exitcode, 
-                                        apr_wait_how_e wait)
+                                        int *exitcode, apr_exit_why_e *exitwhy,
+                                        apr_wait_how_e waithow)
 {
     DWORD stat;
     DWORD time;


______________________________________________________________
Ryan Bloom				rbb@apache.org
Covalent Technologies			rbb@covalent.net
--------------------------------------------------------------

Mime
View raw message