httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r..@hyperreal.org
Subject cvs commit: apache-apr/docs threadproc.txt
Date Fri, 23 Apr 1999 18:00:02 GMT
rbb         99/04/23 11:00:00

  Modified:    apr/test Makefile
               docs     threadproc.txt
  Added:       apr/test testproc.c
               apr/threadproc/unix Makefile proc.c threadproc.h
               include  apr_thread_proc.h
  Log:
  Initial version of the process management stuff.  Also first half of test
  program for process management.  The process management test program requires
  a proctest directory in the test directory, so I have committed that directory
  already.
  
  Revision  Changes    Path
  1.5       +7 -4      apache-apr/apr/test/Makefile
  
  Index: Makefile
  ===================================================================
  RCS file: /home/cvs/apache-apr/apr/test/Makefile,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Makefile	1999/04/23 11:38:13	1.4
  +++ Makefile	1999/04/23 17:59:51	1.5
  @@ -12,12 +12,12 @@
   SRCDIR=..
   EXTRA_CFLAGS=-g 
   EXTRA_LDFLAGS=
  -EXTRA_LIBS= -L../file_io -lfile -L../network_io -lnetwork
  +EXTRA_LIBS=-L../threadproc -lthreadproc -L../file_io -lfile -L../network_io -lnetwork 
   EXTRA_INCLUDES=
   EXTRA_DEPS=
   OSDIR=
   INCDIR=../../include
  -INCLUDES0=-I ../file_io/unix -I ../network_io/unix -I $(INCDIR)
  +INCLUDES0=-I ../file_io/unix -I ../network_io/unix -I ../threadproc/unix -I $(INCDIR)
   SHELL=/bin/sh
   CC=gcc
   CPP=gcc -E
  @@ -45,13 +45,16 @@
   INCLUDES=$(INCLUDES1) $(INCLUDES0) $(EXTRA_INCLUDES)
   LDFLAGS=$(LDFLAGS1) $(EXTRA_LDFLAGS)
   
  -OBJS= testfile.o ab_apr.o
  +OBJS= testfile.o ab_apr.o testproc.o
   
   .c.o:
   	$(CC) -c $(INCLUDES) $(CFLAGS) $(LIBS) $<
   
   all:
  -	testfile ab_apr
  +	testfile ab_apr testproc
  +
  +testproc:
  +	$(CC) testproc.c $(INCLUDES) $(CFLAGS) $(LIBS) $<
   
   testfile:
   	$(CC) testfile.c $(INCLUDES) $(CFLAGS) $(LIBS) $<
  
  
  
  1.1                  apache-apr/apr/test/testproc.c
  
  Index: testproc.c
  ===================================================================
  /* ====================================================================
   * Copyright (c) 1999 The Apache Group.  All rights reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. All advertising materials mentioning features or use of this
   *    software must display the following acknowledgment:
   *    "This product includes software developed by the Apache Group
   *    for use in the Apache HTTP server project (http://www.apache.org/)."
   *
   * 4. The names "Apache Server" and "Apache Group" must not be used to
   *    endorse or promote products derived from this software without
   *    prior written permission. For written permission, please contact
   *    apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * 6. Redistributions of any form whatsoever must retain the following
   *    acknowledgment:
   *    "This product includes software developed by the Apache Group
   *    for use in the Apache HTTP server project (http://www.apache.org/)."
   *
   * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
   * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE APACHE GROUP OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
   * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
   * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
   * OF THE POSSIBILITY OF SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Group.
   * For more information on the Apache Group and the Apache HTTP server
   * project, please see <http://www.apache.org/>.
   *
   */
  
  #include "apr_thread_proc.h"
  #include "apr_errno.h"
  #include "apr_general.h"
  #include "errno.h"
  #include <stdio.h>
  
  int test_filedel(void);
  int testdirs(void);
  
  int main()
  {
      apr_proc_t *newproc;
      apr_procattr_t *attr;
  
      fprintf(stdout, "Creating procattr.......");
      attr = apr_createprocattr_init();
      if (attr == NULL) {
          fprintf(stderr, "Could not create attr\n");
          exit(-1);;
      }
      fprintf(stdout, "OK.\n");
  
      fprintf(stdout, "Setting attr pipes, all three.......");
      if (apr_setprocattr_io(attr, 1, 1, 1) == APR_FAILURE) {
          fprintf(stderr, "Could not set pipes attr\n");
          exit(-1);
      }
      fprintf(stdout, "OK.\n");
      
      fprintf(stdout, "Setting attr dir.......");
      if (apr_setprocattr_dir(attr, "proctest") == APR_FAILURE) {
          fprintf(stderr, "Could not set directory attr\n");
          exit(-1);
      }
      fprintf(stdout, "OK.\n");
  
      fprintf(stdout, "Setting attr cmd type.......");
      if (apr_setprocattr_cmdtype(attr, APR_PROGRAM) == APR_FAILURE) {
          fprintf(stderr, "Could not set cmd type attr\n");
          exit(-1);
      }
      fprintf(stdout, "OK.\n");
  }
  
  
  
  
  1.1                  apache-apr/apr/threadproc/unix/Makefile
  
  Index: Makefile
  ===================================================================
  ##
  ##  Apache Makefile, automatically generated by Configure script.
  ##  Hand-edited changes will be lost if the Configure script is re-run.
  ##  Sources: - ../Makefile.config (via Configuration.apaci)
  ##           - ./Makefile.tmpl
  ##
  
  ##
  ##  Inherited Makefile options from Configure script
  ##  (Begin of automatically generated section)
  ##
  SRCDIR=..
  EXTRA_CFLAGS=-g 
  EXTRA_LDFLAGS=
  EXTRA_LIBS=-L ../../fileio -lfile
  EXTRA_INCLUDES=
  EXTRA_DEPS=
  OSDIR=
  INCDIR=../../../include
  INCLUDES0=-I . -I $(INCDIR) -I ../../file_io/unix
  SHELL=/bin/sh
  CC=gcc
  CPP=gcc -E
  TARGET=
  OPTIM=
  CFLAGS_SHLIB=-fpic -DSHARED_MODULE
  LD_SHLIB=ld
  LDFLAGS_SHLIB=-Bshareable
  LDFLAGS_SHLIB_EXPORT=-rdynamic
  CFLAGS1= -DLINUX=2 -pthread -DUSE_HSREGEX
  INCLUDES1=
  LIBS_SHLIB=
  LDFLAGS1=
  MFLAGS_STATIC=--no-print-directory
  REGLIB=regex/libregex.a
  RANLIB=ranlib
  LIBS1= -lm -lcrypt -lndbm -ldl
  ##
  ##  (End of automatically generated section)
  ##
  
  
  CFLAGS=$(OPTIM) $(CFLAGS1) $(EXTRA_CFLAGS)
  LIBS=$(EXTRA_LIBS) $(LIBS1)
  INCLUDES=$(INCLUDES1) $(INCLUDES0) $(EXTRA_INCLUDES)
  LDFLAGS=$(LDFLAGS1) $(EXTRA_LDFLAGS)
  
  LIB=  libthreadproc.a
  
  OBJS= proc.o 
        
  .c.o:
  	$(CC) -c $(INCLUDES) $(CFLAGS) $<
  
  all: $(HEADERS) $(LIB)
  
  $(LIB): $(OBJS)
  	rm -f $@
  	ar cr $@ $(OBJS)
  	$(RANLIB) $@
  	cp $@ ../
  clean:
  	rm -f *.o $(LIB)
  
  distclean: clean
  	-rm -f Makefile
  
  # We really don't expect end users to use this rule.  It works only with
  # gcc, and rebuilds Makefile.tmpl.  You have to re-run Configure after
  # using it.
  depend:
  	cp Makefile.tmpl Makefile.tmpl.bak \
  	    && sed -ne '1,/^# DO NOT REMOVE/p' Makefile.tmpl > Makefile.new \
  	    && gcc -MM $(INCLUDES) $(CFLAGS) *.c >> Makefile.new \
  	    && sed -e '1,$$s: $(INCDIR)/: $$(INCDIR)/:g' \
  	           -e '1,$$s: $(OSDIR)/: $$(OSDIR)/:g' Makefile.new \
  		> Makefile.tmpl \
  	    && rm Makefile.new
  
  #Dependencies
  
  $(OBJS): Makefile
  
  # DO NOT REMOVE
  open.o: proc.c
  
  
  
  1.1                  apache-apr/apr/threadproc/unix/proc.c
  
  Index: proc.c
  ===================================================================
  /* ====================================================================
   * Copyright (c) 1999 The Apache Group.  All rights reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. All advertising materials mentioning features or use of this
   *    software must display the following acknowledgment:
   *    "This product includes software developed by the Apache Group
   *    for use in the Apache HTTP server project (http://www.apache.org/)."
   *
   * 4. The names "Apache Server" and "Apache Group" must not be used to
   *    endorse or promote products derived from this software without
   *    prior written permission. For written permission, please contact
   *    apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * 6. Redistributions of any form whatsoever must retain the following
   *    acknowledgment:
   *    "This product includes software developed by the Apache Group
   *    for use in the Apache HTTP server project (http://www.apache.org/)."
   *
   * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
   * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE APACHE GROUP OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
   * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
   * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
   * OF THE POSSIBILITY OF SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Group.
   * For more information on the Apache Group and the Apache HTTP server
   * project, please see <http://www.apache.org/>.
   *
   */
  
  #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"
  
  apr_procattr_t *apr_createprocattr_init(void)
  {
      apr_procattr_t *new = (apr_procattr_t *)malloc(sizeof(apr_procattr_t));
  
      new->parent_in = NULL;
      new->child_in = NULL;
      new->parent_out = NULL;
      new->child_out = NULL;
      new->parent_err = NULL;
      new->child_err = NULL;
      new->currdir = NULL; 
      new->cmdtype = APR_PROGRAM;
      return new;
  }
  
  apr_status_t apr_setprocattr_io(apr_procattr_t *attr, apr_int32_t in, 
                                   apr_int32_t out, apr_int32_t err)
  {
      if (in) {
          attr->parent_in = (apr_file_t *)malloc(sizeof(apr_file_t));
          attr->child_in = (apr_file_t *)malloc(sizeof(apr_file_t));
          if (apr_create_pipe(attr->child_in, attr->parent_in) == APR_FAILURE) {
              return APR_FAILURE;
          }
      } 
      if (out) {
          attr->parent_out = (apr_file_t *)malloc(sizeof(apr_file_t));
          attr->child_out = (apr_file_t *)malloc(sizeof(apr_file_t));
          if (apr_create_pipe(attr->parent_out, attr->child_out) == APR_FAILURE) {
              return APR_FAILURE;
          }
      } 
      if (err) {
          attr->parent_err = (apr_file_t *)malloc(sizeof(apr_file_t));
          attr->child_err = (apr_file_t *)malloc(sizeof(apr_file_t));
          if (apr_create_pipe(attr->parent_err, attr->child_err) == APR_FAILURE) {
              return APR_FAILURE;
          }
      } 
  }
  
  apr_status_t apr_setprocattr_dir(apr_procattr_t *attr, char *dir) 
  {
      attr->currdir = strdup(dir);
  }
  
  apr_status_t apr_setprocattr_cmdtype(apr_procattr_t *attr, apr_cmdtype_e cmd) 
  {
      attr->cmdtype = cmd;
  }
  
  apr_int32_t apr_fork(apr_proc_t *proc)
  {
      int pid;
  
      if ((pid = fork()) < 0) {
          return -1;
      }
      else if (pid == 0) {
          proc->pid = pid;
          proc->attr = NULL;
          return pid;
      }
      proc->pid = pid;
      proc->attr = NULL;
      return 1;
  }
  
  apr_proc_t *apr_create_process(char *progname, char *args, char **env, apr_procattr_t *attr)
  {
      apr_proc_t *new = (apr_proc_t *)malloc(sizeof(apr_proc_t));
  
      if ((new->pid = fork()) < 0) {
          return NULL;
      }
      else if (new->pid == 0) { 
          /* child process */
          if (attr->child_in) {
              apr_close(attr->parent_in);
              dup2(attr->child_in->filedes, STDIN_FILENO);
              apr_close(attr->child_in);
          }
          if (attr->child_out) {
              apr_close(attr->parent_out);
              dup2(attr->child_out->filedes, STDOUT_FILENO);
              apr_close(attr->child_out);
          }
          if (attr->child_err) {
              apr_close(attr->parent_err);
              dup2(attr->child_err->filedes, STDERR_FILENO);
              apr_close(attr->child_err);
          }
          
          signal(SIGCHLD, SIG_DFL); /*not sure if this is needed or not */
  
          if (attr->currdir != NULL) {
              if (chdir(attr->currdir) == -1) {
                  free(new);
                  exit(-1);   /* We have big problems, the child should exit. */
              }
          }
          
          if (attr->cmdtype == APR_SHELLCMD) {
              execle(SHELL_PATH, SHELL_PATH, "-c", args, NULL, env);
          }
          else {
              execle(progname, args, NULL, env);
          }
          exit(-1);  /* if we get here, there is a problem, so exit with an */ 
                     /* error code. */
      }
      /* Parent process */
      if (attr->child_in) {
          apr_close(attr->child_in);
      }
      if (attr->child_out) {
          apr_close(attr->child_out);
      }
      if (attr->child_err) {
          apr_close(attr->child_err);
      }
      
      new->attr = attr;
  }
  
  apr_file_t *apr_get_childin(apr_proc_t *proc)
  {
      return proc->attr->parent_in; 
  }
  
  apr_file_t *apr_get_childout(apr_proc_t *proc)
  {
      return proc->attr->parent_out; 
  }
  
  apr_file_t *apr_get_childerr(apr_proc_t *proc)
  {
      return proc->attr->parent_err; 
  }    
  
  
  
  
  1.1                  apache-apr/apr/threadproc/unix/threadproc.h
  
  Index: threadproc.h
  ===================================================================
  /* ====================================================================
   * Copyright (c) 1999 The Apache Group.  All rights reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. All advertising materials mentioning features or use of this
   *    software must display the following acknowledgment:
   *    "This product includes software developed by the Apache Group
   *    for use in the Apache HTTP server project (http://www.apache.org/)."
   *
   * 4. The names "Apache Server" and "Apache Group" must not be used to
   *    endorse or promote products derived from this software without
   *    prior written permission. For written permission, please contact
   *    apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * 6. Redistributions of any form whatsoever must retain the following
   *    acknowledgment:
   *    "This product includes software developed by the Apache Group
   *    for use in the Apache HTTP server project (http://www.apache.org/)."
   *
   * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
   * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE APACHE GROUP OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
   * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
   * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
   * OF THE POSSIBILITY OF SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Group.
   * For more information on the Apache Group and the Apache HTTP server
   * project, please see <http://www.apache.org/>.
   *
   */
  
  #include "apr_thread_proc.h"
  #include "apr_file_io.h"
  #include <pthread.h>
  
  #ifndef THREAD_PROC_H
  #define THREAD_PROC_H
  
  #define SHELL_PATH "/bin/sh"
  
  struct thread_t {
      pthread_t *td;
      pthread_attr_t *attr;
  };
  
  struct procattr_t {
      apr_file_t *parent_in;
      apr_file_t *child_in;
      apr_file_t *parent_out;
      apr_file_t *child_out;
      apr_file_t *parent_err;
      apr_file_t *child_err;
      char *currdir;
      apr_int32_t cmdtype;
  };
  
  struct proc_t {
      pid_t pid;
      struct procattr_t *attr;
  };
  
  #endif  /* ! THREAD_PROC_H */
  
  
  
  
  1.1                  apache-apr/include/apr_thread_proc.h
  
  Index: apr_thread_proc.h
  ===================================================================
  /* ====================================================================
   * Copyright (c) 1999 The Apache Group.  All rights reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. All advertising materials mentioning features or use of this
   *    software must display the following acknowledgment:
   *    "This product includes software developed by the Apache Group
   *    for use in the Apache HTTP server project (http://www.apache.org/)."
   *
   * 4. The names "Apache Server" and "Apache Group" must not be used to
   *    endorse or promote products derived from this software without
   *    prior written permission. For written permission, please contact
   *    apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * 6. Redistributions of any form whatsoever must retain the following
   *    acknowledgment:
   *    "This product includes software developed by the Apache Group
   *    for use in the Apache HTTP server project (http://www.apache.org/)."
   *
   * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
   * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE APACHE GROUP OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
   * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
   * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
   * OF THE POSSIBILITY OF SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Group.
   * For more information on the Apache Group and the Apache HTTP server
   * project, please see <http://www.apache.org/>.
   *
   */
  
  #ifndef APR_THREAD_PROC_H
  #define APR_THREAD_PROC_H
  
  #include "threadproc.h"
  #include "apr_general.h"
  #include "apr_errno.h"
  
  typedef enum {APR_SHELLCMD, APR_PROGRAM} apr_cmdtype_e;
  
  typedef struct thread_t           apr_thread_t;
  typedef struct proc_t		  apr_proc_t;
  typedef struct procattr_t         apr_procattr_t;
  
  /*   Function definitions */
  apr_procattr_t *apr_createprocattr_init(void);
  apr_status_t apr_setprocattr_io(apr_procattr_t *, apr_int32_t, apr_int32_t, apr_int32_t);
  apr_status_t apr_setprocattr_dir(apr_procattr_t *, char *);
  apr_status_t apr_setprocattr_cmdtype(apr_procattr_t *, apr_cmdtype_e);
  
  apr_file_t *apr_get_childin(apr_proc_t *);
  apr_file_t *apr_get_childout(apr_proc_t *);
  apr_file_t *apr_get_childerr(apr_proc_t *);
  
  apr_int32_t apr_fork(apr_proc_t *);
  apr_proc_t *apr_create_process(char *, char *, char **, apr_procattr_t *);
  
  #endif  /* ! APR_FILE_IO_H */
  
  
  
  
  
  
  1.3       +37 -8     apache-apr/docs/threadproc.txt
  
  Index: threadproc.txt
  ===================================================================
  RCS file: /home/cvs/apache-apr/docs/threadproc.txt,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- threadproc.txt	1999/04/20 20:46:43	1.2
  +++ threadproc.txt	1999/04/23 18:00:00	1.3
  @@ -1,4 +1,8 @@
   ---------------------------Thread/Process abstraction
  +
  +NOTE:  There is a one-to-one mapping between process and process_attr's.  This
  +       relationship does not exist with threads and thread_attr's.
  +
    apr_thread_t *apr_create_thread(void * (void *), void *,
   	      APRUInt32)
   	Create a new thread
  @@ -14,8 +18,9 @@
   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.
  -        return) status.  APR_FAILURE on error, 0 if child process, 1 if original
  +        arg 1)  the proccess type for the newly created process.  NULL on error.
  +                which fields are filled out in this structure is undefined.
  +        return) status.  -1 on error, 0 if child process, 1 if original
                   process.
   NOTE:  This is a non-portable call.  It cannot be avoided, and any system that 
          can create this function should do so.  Any platform that is not able
  @@ -35,8 +40,10 @@
           arg 3)  Should we setup a pipe for stdout? 1 yes, 0 no
           arg 4)  Should we setup a pipe for stderr? 1 yes, 0 no.
           return) APR_SUCCESS or APR_FAILURE
  -NOTE:  the file structures are a part of the process atr variable.  They are
  -       created and filled out by this func. 
  +NOTE:  the file structures are a part of the process attr variable.  They are
  +       created and filled out by this func.  On UNIX, this function actually
  +       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 *)
          define starting directory for new process.
  @@ -55,11 +62,33 @@
   	arg 4)  a pointer to structure that describes the attributes of the new
   		process.  If NULL, process will have the default attributes.
   	return) Process description structure.
  - APRStatus apr_procsetcurrdir(APRPROCESSATTR *, char *);
  -	change the current directory of the process attribute structure.
  +
  +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
  +     Arguments:
  +        arg 1)  The process that spawned the child
  +        return) The file to use when writing to the child's stdin.  NULL
  +                on error. 
  +
  +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
  +     Arguments:
  +        arg 1)  The process that spawned the child
  +        return) The file to use when reading from the child's stdout.  NULL
  +                on error. 
  +
  +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
        Arguments:
  -	arg 1)  Structure to change the dir in.
  -	arg 2)	Path to change the directory to in the APRPROCESSATTR struct.
  +        arg 1)  The process that spawned the child
  +        return) The file to use when reading from the child's stderr.  NULL
  +                on error.   
   
    APRStatus  apr_get_thread_private(APRUInt32, APThdPriv)
           Get the thread private data for the current thread
  
  
  

Mime
View raw message