rbb         99/04/26 11:16:51

  Modified:    apr/threadproc/unix proc.c
               docs     threadproc.txt
               include  apr_thread_proc.h
  Log:
  New process function.  Wait's for a process to die, and let's the caller
  know the result.
  
  Revision  Changes    Path
  1.4       +17 -2     apache-apr/apr/threadproc/unix/proc.c
  
  Index: proc.c
  ===================================================================
  RCS file: /home/cvs/apache-apr/apr/threadproc/unix/proc.c,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- proc.c    1999/04/26 15:35:18     1.3
  +++ proc.c    1999/04/26 18:16:39     1.4
  @@ -56,10 +56,11 @@
   #include "apr_thread_proc.h"
   #include "apr_file_io.h"
   #include "apr_general.h"
  -#include <string.h>
  -#include <signal.h>
   #include "threadproc.h"
   #include "fileio.h"
  +#include <signal.h>
  +#include <string.h>
  +#include <sys/wait.h>
   
   apr_procattr_t *apr_createprocattr_init(void)
   {
  @@ -215,4 +216,18 @@
   {
       return proc->attr->parent_err; 
   }    
  +
  +apr_status_t apr_wait_proc(apr_proc_t *proc, apr_wait_how_e wait)
  +{
  +    if (!proc)
  +        return APR_FAILURE;
  +    if (wait == APR_WAIT) {
  +        if (waitpid(proc->pid, NULL, WUNTRACED) > 0)
  +            return APR_SUCCESS;
  +        return APR_FAILURE;
  +    }
  +    if (waitpid(proc->pid, NULL, WUNTRACED | WNOHANG) > 0)
  +        return APR_SUCCESS;
  +    return APR_FAILURE;
  +} 
   
  
  
  
  1.7       +19 -9     apache-apr/docs/threadproc.txt
  
  Index: threadproc.txt
  ===================================================================
  RCS file: /home/cvs/apache-apr/docs/threadproc.txt,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- threadproc.txt    1999/04/26 17:22:30     1.6
  +++ threadproc.txt    1999/04/26 18:16:44     1.7
  @@ -15,7 +15,7 @@
                specific default size.
        return) The thread created.
   
  -apr_int32_t apr_fork(apr_proc_t *)
  + apr_int32_t apr_fork(apr_proc_t *)
           create a new process with a copy of the currently executing address 
space.
        Arguments:
           arg 1)  the proccess type for the newly created process.  NULL on 
error.
  @@ -27,12 +27,12 @@
          to produce this function should define it as NULL, so that there are
          no compile time errors. 
           
  -apr_procattr_t *apr_createprocattr_init(void);
  + apr_procattr_t *apr_createprocattr_init(void);
           create a new process attr type with OS dependant defaults
        Arguments:
           return) New process attribute type.
   
  -apr_status_t apr_setprocattr_io(apr_procattr_t *, apr_int32_t, apr_int32_t, 
apr_int32_t)
  + apr_status_t apr_setprocattr_io(apr_procattr_t *, apr_int32_t, apr_int32_t, 
apr_int32_t)
           setup stdin, stdout, and stderr attributes for the new proc
        Arguments
           arg 1)  the process attr to modify
  @@ -45,14 +45,14 @@
          creates the pipe(s), but lets apr_create_process set them up as 
          std(in|out|err).
   
  -apr_status_t apr_setprocattr_dir(apr_procattr_t *, char *)
  + apr_status_t apr_setprocattr_dir(apr_procattr_t *, char *)
          define starting directory for new process.
        Arguments
          arg 1)  The process attr to modify
          arg 2)  The starting directory for the new process.
          return) APR_SUCCESS or APR_FAILURE
   
  -apr_proc_t *apr_create_process(char *, char *const [], char **, const 
apr_procattr_t *)
  + apr_proc_t *apr_create_process(char *, char *const [], char **, const 
apr_procattr_t *)
        create a new process and run a new executable in it.
        Arguments:
        arg 1)  Path name of the executable file 
  @@ -64,7 +64,7 @@
                process.  If NULL, process will have the default attributes.
        return) Process description structure.  NULL on failure
   
  -apr_file_t *apr_get_childin(apr_proc_t *)
  + apr_file_t *apr_get_childin(apr_proc_t *)
           Get the parent side of the pipe that connects to the child's stdin.
           This function is only valid after a process has successfully spawned
           a child
  @@ -73,7 +73,7 @@
           return) The file to use when writing to the child's stdin.  NULL
                   on error. 
   
  -apr_file_t *apr_get_childout(apr_proc_t *)
  + apr_file_t *apr_get_childout(apr_proc_t *)
           Get the parent side of the pipe that connects to the child's stdout.
           This function is only valid after a process has successfully spawned
           a child
  @@ -82,7 +82,7 @@
           return) The file to use when reading from the child's stdout.  NULL
                   on error. 
   
  -apr_file_t *apr_get_childerr(apr_proc_t *)
  + apr_file_t *apr_get_childerr(apr_proc_t *)
           Get the parent side of the pipe that connects to the child's stderr.
           This function is only valid after a process has successfully spawned
           a child
  @@ -91,6 +91,15 @@
           return) The file to use when reading from the child's stderr.  NULL
                   on error.   
   
  + apr_status_t apr_wait_proc(apr_proc_t *, apr_wait_how_e) 
  +        Wait for a specified process to exit
  +     Arguments:
  +        arg 1)  The process to wait for.
  +        arg 2)  wait for a process to die, or return immediately
  +                APR_WAIT
  +                APR_NOWAIT
  +        return) APR_SUCCESS or APR_fAILURE
  +
    APRStatus  apr_get_thread_private(APRUInt32, APThdPriv)
           Get the thread private data for the current thread
        Arguments:
  @@ -116,5 +125,6 @@
   
   struct apr_thread_t {
       pthread_t td;
  -    
  +    apr_procattr_t attr;
  +} 
     
  
  
  
  1.3       +2 -0      apache-apr/include/apr_thread_proc.h
  
  Index: apr_thread_proc.h
  ===================================================================
  RCS file: /home/cvs/apache-apr/include/apr_thread_proc.h,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- apr_thread_proc.h 1999/04/26 15:35:19     1.2
  +++ apr_thread_proc.h 1999/04/26 18:16:48     1.3
  @@ -61,6 +61,7 @@
   #include "apr_errno.h"
   
   typedef enum {APR_SHELLCMD, APR_PROGRAM} apr_cmdtype_e;
  +typedef enum {APR_WAIT, APR_NOWAIT} apr_wait_how_e;
   
   typedef struct thread_t           apr_thread_t;
   typedef struct proc_t                  apr_proc_t;
  @@ -78,6 +79,7 @@
   
   apr_int32_t apr_fork(apr_proc_t *);
   apr_proc_t *apr_create_process(char *, char *const [], char **, 
apr_procattr_t *);
  +apr_wait_proc(apr_proc_t *, apr_wait_how_e);
   
   #endif  /* ! APR_FILE_IO_H */
   
  
  
  

Reply via email to