apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jerenkra...@apache.org
Subject cvs commit: apr/threadproc/unix proc.c
Date Fri, 21 Sep 2001 16:14:50 GMT
jerenkrantz    01/09/21 09:14:50

  Modified:    .        CHANGES
               threadproc/unix proc.c
  Log:
  Simplify apr_proc_wait_all_procs and consolidate apr_proc_wait.
  
  (I had a similar version in my tree.  Kevin's wins out because of the
  WIF macros.  Are there any platforms that don't have this?  The Solaris
  man page seems to indicate that they must be called, so it seems correct.
  Please check on your favorite platform.)
  
  Submitted by:	Kevin Pilch-Bisson <kevin@pilch-bisson.net>
  Reviewed by:	Justin Erenkrantz
  
  Revision  Changes    Path
  1.159     +5 -0      apr/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/apr/CHANGES,v
  retrieving revision 1.158
  retrieving revision 1.159
  diff -u -r1.158 -r1.159
  --- CHANGES	2001/09/19 20:08:05	1.158
  +++ CHANGES	2001/09/21 16:14:50	1.159
  @@ -1,5 +1,10 @@
   Changes with APR b1  
   
  +  *) Make the unix version of apr_proc_wait_all_procs a simple wrapper 
  +     around apr_proc_wait, and which extracts the exit code from the 
  +     status returned by waitpid.  
  +     [Kevin Pilch-Bisson <kevin@pilch-bisson.net>]
  +
     *) Add process locking API to APR. [Aaron Bannert <aaron@clove.org>]
   
     *) Add condition variables for Windows.  [Ryan Bloom]
  
  
  
  1.49      +21 -24    apr/threadproc/unix/proc.c
  
  Index: proc.c
  ===================================================================
  RCS file: /home/cvs/apr/threadproc/unix/proc.c,v
  retrieving revision 1.48
  retrieving revision 1.49
  diff -u -r1.48 -r1.49
  --- proc.c	2001/09/20 08:59:31	1.48
  +++ proc.c	2001/09/21 16:14:50	1.49
  @@ -361,22 +361,13 @@
       return APR_SUCCESS;
   }
   
  -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, 
  +                                                  apr_wait_t *status,
  +                                                  apr_wait_how_e waithow, 
  +                                                  apr_pool_t *p)
   {
  -    int waitpid_options = WUNTRACED;
  -
  -    if (waithow != APR_WAIT) {
  -        waitpid_options |= WNOHANG;
  -    }
  -
  -    if ((proc->pid = waitpid(-1, status, waitpid_options)) > 0) {
  -        return APR_CHILD_DONE;
  -    }
  -    else if (proc->pid == 0) {
  -        return APR_CHILD_NOTDONE;
  -    }
  -    return errno;
  +    proc->pid = -1;
  +    return apr_proc_wait(proc, status, waithow);
   } 
   
   APR_DECLARE(apr_status_t) apr_proc_wait(apr_proc_t *proc, 
  @@ -384,18 +375,24 @@
                                           apr_wait_how_e waithow)
   {
       pid_t pstatus;
  +    int waitpid_options = WUNTRACED;
  +    int exit_int;
   
  -    if (waithow == APR_WAIT) {
  -        if ((pstatus = waitpid(proc->pid, exitcode, WUNTRACED)) > 0) {
  -            return APR_CHILD_DONE;
  +    if (waithow != APR_WAIT) {
  +        waitpid_options |= WNOHANG;
  +    }
  +    
  +    if ((pstatus = waitpid(proc->pid, &exit_int, waitpid_options)) > 0) {
  +        if (proc->pid == -1) {
  +            proc->pid = pstatus;
           }
  -        else if (pstatus == 0) {
  -            return APR_CHILD_NOTDONE;
  +        if (WIFEXITED(exit_int)) {
  +            if (exitcode != NULL) {
  +                *exitcode = WEXITSTATUS(exit_int);
  +            }
  +            return APR_CHILD_DONE;
           }
  -        return errno;
  -    }
  -    if ((pstatus = waitpid(proc->pid, exitcode, WUNTRACED | WNOHANG)) > 0) {
  -        return APR_CHILD_DONE;
  +        return APR_CHILD_NOTDONE;
       }
       else if (pstatus == 0) {
           return APR_CHILD_NOTDONE;
  
  
  

Mime
View raw message