see patch... seems simple enough, but perhaps somebody knows some showstoppers that would prevent this from being implemented on some platform?

also, maybe there is a preferred name for the function?

Index: include/apr_thread_proc.h
===================================================================
RCS file: /home/cvs/apr/include/apr_thread_proc.h,v
retrieving revision 1.99
diff -u -r1.99 apr_thread_proc.h
--- include/apr_thread_proc.h   3 Nov 2003 15:44:41 -0000       1.99
+++ include/apr_thread_proc.h   7 Nov 2003 15:20:59 -0000
@@ -737,6 +737,13 @@
 APR_DECLARE(apr_status_t) apr_proc_kill(apr_proc_t *proc, int sig);
 
 /**
+ * See if a process is alive.
+ * @param proc The process to check.
+ * @return APR_SUCCESS if the process is still alive.
+ */
+APR_DECLARE(apr_status_t) apr_proc_check(apr_proc_t *proc);
+
+/**
  * Register a process to be killed when a pool dies.
  * @param a The pool to use to define the processes lifetime 
  * @param proc The process to register
Index: threadproc/unix/proc.c
===================================================================
RCS file: /home/cvs/apr/threadproc/unix/proc.c,v
retrieving revision 1.71
diff -u -r1.71 proc.c
--- threadproc/unix/proc.c      6 Nov 2003 00:25:33 -0000       1.71
+++ threadproc/unix/proc.c      7 Nov 2003 15:21:00 -0000
@@ -636,3 +636,18 @@
 
     return APR_SUCCESS;
 }
+
+APR_DECLARE(apr_status_t) apr_proc_check(apr_proc_t *proc)
+{
+#ifdef _AIX
+    /* On AIX, for processes like mod_cgid's script children where
+     * SIGCHLD is ignored, kill(pid,0) returns success for up to
+     * one second after the script child exits, based on when a
+     * daemon runs to clean up unnecessary process table entries.
+     * getpgid() can report the proper info (-1/ESRCH) immediately.
+     */
+    return (getpgid(proc->pid) < 0) ? errno : APR_SUCCESS;
+#else
+    return (kill(proc->pid, 0) < 0) ? errno : APR_SUCCESS;
+#endif
+}

Reply via email to