From dev-return-10586-apmail-apr-dev-archive=apr.apache.org@apr.apache.org Fri Nov 07 15:23:43 2003 Return-Path: Delivered-To: apmail-apr-dev-archive@www.apache.org Received: (qmail 55519 invoked from network); 7 Nov 2003 15:23:43 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 7 Nov 2003 15:23:43 -0000 Received: (qmail 91387 invoked by uid 500); 7 Nov 2003 15:23:37 -0000 Delivered-To: apmail-apr-dev-archive@apr.apache.org Received: (qmail 91219 invoked by uid 500); 7 Nov 2003 15:23:36 -0000 Mailing-List: contact dev-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Delivered-To: mailing list dev@apr.apache.org Received: (qmail 91206 invoked from network); 7 Nov 2003 15:23:36 -0000 Message-ID: <3FABB8F4.4040506@attglobal.net> Date: Fri, 07 Nov 2003 10:23:32 -0500 From: Jeff Trawick Reply-To: trawick@attglobal.net User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.5) Gecko/20031007 X-Accept-Language: en-us, en MIME-Version: 1.0 To: dev@apr.apache.org Subject: [PATCH] apr function to see if an arbitrary process is alive Content-Type: multipart/mixed; boundary="------------050302010405010307030506" X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N This is a multi-part message in MIME format. --------------050302010405010307030506 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit 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? --------------050302010405010307030506 Content-Type: text/plain; name="apr_proc_check" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="apr_proc_check" 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 +} --------------050302010405010307030506--