apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dr...@apache.org
Subject cvs commit: apr/threadproc/beos proc.c thread.c
Date Sun, 28 Oct 2001 13:46:15 GMT
dreid       01/10/28 05:46:15

  Modified:    threadproc/beos proc.c thread.c
  Log:
  Some more tidying up for the beos code and get it building again.
  
  Revision  Changes    Path
  1.42      +38 -29    apr/threadproc/beos/proc.c
  
  Index: proc.c
  ===================================================================
  RCS file: /home/cvs/apr/threadproc/beos/proc.c,v
  retrieving revision 1.41
  retrieving revision 1.42
  diff -u -r1.41 -r1.42
  --- proc.c	2001/10/23 17:30:08	1.41
  +++ proc.c	2001/10/28 13:46:15	1.42
  @@ -283,46 +283,55 @@
   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)
  +                                                  apr_wait_how_e waithow, 
  +                                                  apr_pool_t *p)
   {
  +    proc->pid = -1;
  +    return apr_proc_wait(proc, exitcode, exitwhy, waithow);
  +} 
  +
  +APR_DECLARE(apr_status_t) apr_proc_wait(apr_proc_t *proc,
  +                                        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 ((proc->pid = waitpid(-1, status, waitpid_options)) > 0) {
  +    
  +    if ((pstatus = waitpid(proc->pid, &exit_int, waitpid_options)) > 0) {
  +        proc->pid = pstatus;
  +        if (WIFEXITED(exit_int)) {
  +            *exitwhy = APR_PROC_EXIT;
  +            *exitcode = WEXITSTATUS(exit_int);
  +        }
  +        else if (WIFSIGNALED(exit_int)) {
  +            *exitwhy = APR_PROC_SIGNAL;
  +            *exitcode = WTERMSIG(exit_int);
  +        }
  +        else {
  +            /* unexpected condition */
  +            return APR_EGENERAL;
  +        }
           return APR_CHILD_DONE;
       }
  -    else if (proc->pid == 0) {
  +    else if (pstatus == 0) {
           return APR_CHILD_NOTDONE;
       }
       return errno;
  -} 
  -
  -APR_DECLARE(apr_status_t) apr_proc_wait(apr_proc_t *proc,
  -                                        int *exitcode, apr_exit_why_e *exitwhy,
  -                                        apr_wait_how_e waithow)
  -{
  -    status_t rv;
  -
  -    if (!proc)
  -        return APR_ENOPROC;
  -    /* when we run processes we are actually running threads, so here
  -       we'll wait on the thread dying... */
  -    if (wait == APR_WAIT) {
  -        if ((rv = wait_for_thread(proc->pid, exitcode)) == B_OK) {
  -            return APR_CHILD_DONE;
  -        }
  -        return rv;
  -    }
  -    /* if the thread is still alive then it's not done...
  -       this won't hang or holdup the thread checking... */
  -    if (resume_thread(proc->pid) == B_BAD_THREAD_ID) {
  -        return APR_CHILD_DONE;
  -    }
  -    /* if we get this far it's still going... */
  -    return APR_CHILD_NOTDONE;
   } 
   
   APR_DECLARE(apr_status_t) apr_procattr_child_in_set(apr_procattr_t *attr, apr_file_t *child_in,
  
  
  
  1.28      +4 -3      apr/threadproc/beos/thread.c
  
  Index: thread.c
  ===================================================================
  RCS file: /home/cvs/apr/threadproc/beos/thread.c,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- thread.c	2001/09/11 13:33:39	1.27
  +++ thread.c	2001/10/28 13:46:15	1.28
  @@ -144,14 +144,15 @@
   APR_DECLARE(apr_status_t) apr_thread_exit(apr_thread_t *thd, apr_status_t *retval)
   {
       apr_pool_destroy(thd->cntxt);
  -	exit_thread ((status_t)(*retval));
  -	return APR_SUCCESS;
  +    exit_thread ((status_t)(*retval));
  +    /* This will never be reached... */
  +    return APR_SUCCESS;
   }
   
   APR_DECLARE(apr_status_t) apr_thread_join(apr_status_t *retval, apr_thread_t *thd)
   {
       status_t rv = 0, ret;
  -    if ((ret = wait_for_thread(thd->td,&rv)) == B_NO_ERROR) {
  +    if ((ret = wait_for_thread(thd->td, &rv)) == B_NO_ERROR) {
           *retval = rv;
           return APR_SUCCESS;
       }
  
  
  

Mime
View raw message