--- ./srclib/apr/memory/unix/apr_pools.c.orig	2002-07-14 00:38:02.000000000 +0300
+++ ./srclib/apr/memory/unix/apr_pools.c	2002-10-20 22:14:09.000000000 +0300
@@ -86,6 +86,17 @@
 #define BOUNDARY_INDEX 12
 #define BOUNDARY_SIZE (1 << BOUNDARY_INDEX)
 
+/* 
+ * Timing constants for killing subprocesses
+ * There is a total 3-second delay between sending a SIGINT 
+ * and sending of the final SIGKILL, but we poll the status
+ * every 0.1 seconds to see if the subprocess has exited early 
+ * to avoid doing a full 3-second wait which otherwise would
+ * cause a keepalive-client to experience the full wait.
+ */
+#define TIMEOUT_USECS    3000000
+#define TIMEOUT_INTERVAL  100000
+#define TIMEOUT_ITERS    (TIMEOUT_USECS / TIMEOUT_INTERVAL)
 
 /*
  * Allocator
@@ -2032,6 +2043,7 @@
      */
     struct process_chain *pc;
     int need_timeout = 0;
+    int timeout_iters = TIMEOUT_ITERS;
 
     if (!procs)
         return; /* No work.  Whew! */
@@ -2073,8 +2085,18 @@
     }
 
     /* Sleep only if we have to... */
-    if (need_timeout)
-        apr_sleep(apr_time_from_sec(3));
+    while (need_timeout && --timeout_iters >= 0) {
+      apr_sleep(TIMEOUT_INTERVAL);
+      need_timeout = 0;
+      /* check the status of the subprocesses */
+      for (pc = procs; pc; pc = pc->next) {
+        if (pc->kill_how == APR_KILL_AFTER_TIMEOUT &&
+	    apr_proc_wait(pc->pid, NULL, NULL, APR_NOWAIT) != APR_CHILD_NOTDONE)
+	  pc->kill_how = APR_KILL_NEVER;	/* subprocess has exited */
+	else
+	  need_timeout = 1;		/* subprocess is still active */
+      }
+    }
 
     /* OK, the scripts we just timed out for have had a chance to clean up
      * --- now, just get rid of them, and also clean up the system accounting
