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/include apr_errno.h
Date Thu, 17 Jun 1999 15:05:25 GMT
rbb         99/06/17 08:05:25

  Modified:    apr      configure.in
               apr/include apr_config.h.in
               apr/threadproc/unix Makefile.in proc.c threadproc.h
               include  apr_errno.h
  Added:       apr/threadproc/unix procsup.c
  Log:
  Unix can now create processes that are supposed to be detached.  Not tested,
  but I'll get to that later.
  
  Revision  Changes    Path
  1.22      +1 -1      apache-apr/apr/configure.in
  
  Index: configure.in
  ===================================================================
  RCS file: /home/cvs/apache-apr/apr/configure.in,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- configure.in	1999/06/16 11:15:56	1.21
  +++ configure.in	1999/06/17 15:05:17	1.22
  @@ -162,7 +162,7 @@
   AC_FUNC_SETPGRP
   
   dnl Checks for library functions.
  -AC_CHECK_FUNCS(strcasecmp stricmp poll)
  +AC_CHECK_FUNCS(strcasecmp stricmp poll setsid)
   
   dnl Start building stuff from our information
   AC_SUBST(LDLIBS)
  
  
  
  1.8       +2 -1      apache-apr/apr/include/apr_config.h.in
  
  Index: apr_config.h.in
  ===================================================================
  RCS file: /home/cvs/apache-apr/apr/include/apr_config.h.in,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- apr_config.h.in	1999/06/15 19:43:26	1.7
  +++ apr_config.h.in	1999/06/17 15:05:19	1.8
  @@ -73,7 +73,8 @@
   #undef HAVE_MMAP
   #undef HAVE_STRCASECMP
   #undef HAVE_STRICMP
  -
  +#undef HAVE_POLL
  +#undef HAVE_SETSID
   /*
    * Known problems with system header files that we can fix.
    */
  
  
  
  1.4       +16 -5     apache-apr/apr/threadproc/unix/Makefile.in
  
  Index: Makefile.in
  ===================================================================
  RCS file: /home/cvs/apache-apr/apr/threadproc/unix/Makefile.in,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Makefile.in	1999/06/15 19:43:48	1.3
  +++ Makefile.in	1999/06/17 15:05:21	1.4
  @@ -17,6 +17,7 @@
   LIB=../libthreadproc.a
   
   OBJS=proc.o \
  +	procsup.o \
   	thread.o \
   	threadcancel.o \
   	threadpriv.o \
  @@ -57,16 +58,26 @@
   # DO NOT REMOVE
   proc.o: proc.c threadproc.h ../../../include/apr_thread_proc.h \
    ../../../include/apr_file_io.h ../../../include/apr_general.h \
  - ../../../include/apr_errno.h ../../file_io/unix/fileio.h
  + $(INCDIR)/apr_config.h ../../../include/apr_errno.h \
  + ../../file_io/unix/fileio.h $(INCDIR)/apr_lib.h \
  + $(INCDIR)/hsregex.h
  +procsup.o: procsup.c threadproc.h ../../../include/apr_thread_proc.h \
  + ../../../include/apr_file_io.h ../../../include/apr_general.h \
  + $(INCDIR)/apr_config.h ../../../include/apr_errno.h \
  + ../../file_io/unix/fileio.h $(INCDIR)/apr_lib.h \
  + $(INCDIR)/hsregex.h
   signals.o: signals.c threadproc.h ../../../include/apr_thread_proc.h \
    ../../../include/apr_file_io.h ../../../include/apr_general.h \
  - ../../../include/apr_errno.h ../../file_io/unix/fileio.h
  + $(INCDIR)/apr_config.h ../../../include/apr_errno.h \
  + ../../file_io/unix/fileio.h
   thread.o: thread.c threadproc.h ../../../include/apr_thread_proc.h \
    ../../../include/apr_file_io.h ../../../include/apr_general.h \
  - ../../../include/apr_errno.h
  + $(INCDIR)/apr_config.h ../../../include/apr_errno.h
   threadcancel.o: threadcancel.c threadproc.h \
    ../../../include/apr_thread_proc.h ../../../include/apr_file_io.h \
  - ../../../include/apr_general.h ../../../include/apr_errno.h
  + ../../../include/apr_general.h $(INCDIR)/apr_config.h \
  + ../../../include/apr_errno.h
   threadpriv.o: threadpriv.c threadproc.h \
    ../../../include/apr_thread_proc.h ../../../include/apr_file_io.h \
  - ../../../include/apr_general.h ../../../include/apr_errno.h
  + ../../../include/apr_general.h $(INCDIR)/apr_config.h \
  + ../../../include/apr_errno.h
  
  
  
  1.18      +7 -0      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.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- proc.c	1999/06/16 19:30:19	1.17
  +++ proc.c	1999/06/17 15:05:22	1.18
  @@ -158,6 +158,7 @@
   {
       int i;
       char **newargs;
  +    struct proc_t *pgrp; 
   
       (*new) = (struct proc_t *)ap_palloc(cont, sizeof(struct proc_t));
   
  @@ -209,9 +210,15 @@
                   i++;
               }
               newargs[i + 3] = NULL;
  +            if (attr->detached) {
  +                ap_detach(attr->cntxt, &pgrp);
  +            }
               execve(SHELL_PATH, newargs, env);
           }
           else {
  +            if (attr->detached) {
  +                ap_detach(attr->cntxt, &pgrp);
  +            }
               execve(progname, args, env);
           }
           exit(-1);  /* if we get here, there is a problem, so exit with an */ 
  
  
  
  1.7       +6 -0      apache-apr/apr/threadproc/unix/threadproc.h
  
  Index: threadproc.h
  ===================================================================
  RCS file: /home/cvs/apache-apr/apr/threadproc/unix/threadproc.h,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- threadproc.h	1999/05/21 19:53:57	1.6
  +++ threadproc.h	1999/06/17 15:05:23	1.7
  @@ -87,6 +87,7 @@
       ap_file_t *child_err;
       char *currdir;
       ap_int32_t cmdtype;
  +    ap_int32_t detached;
   };
   
   struct proc_t {
  @@ -94,6 +95,11 @@
       pid_t pid;
       struct procattr_t *attr;
   };
  +
  +/*This will move to apr_threadproc.h in time, but I need to figure it out
  + * on windows first.  :)
  + */
  +ap_status_t ap_detach(ap_context_t *, struct proc_t **);
   
   #endif  /* ! THREAD_PROC_H */
   
  
  
  
  1.1                  apache-apr/apr/threadproc/unix/procsup.c
  
  Index: procsup.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 "threadproc.h"
  #include "fileio.h"
  
  #include "apr_config.h"
  #include "apr_thread_proc.h"
  #include "apr_file_io.h"
  #include "apr_general.h"
  #include "apr_lib.h"
  
  ap_status_t ap_detach(ap_context_t *cont, struct proc_t **new)
  {
      int x;
  
      (*new) = (struct proc_t *)ap_palloc(cont, sizeof(struct proc_t));
      (*new)->cntxt = cont;
      (*new)->attr = NULL;
  
      chdir("/");
  #if !defined(MPE) && !defined(OS2) && !defined(TPF)
  /* Don't detach for MPE because child processes can't survive the death of
     the parent. */
      if ((x = fork()) > 0)
          exit(0);
      else if (x == -1) {
          perror("fork");
          fprintf(stderr, "unable to fork new process\n");
          exit(1);  /* we can't do anything here, so just exit. */
      }
      RAISE_SIGSTOP(DETACH);
  #endif
  #if HAVE_SETSID
      if (((*new)->pid = setsid()) == -1) {
          return errno;
      }
  #elif defined(NEXT) || defined(NEWSOS)
      if (setpgrp(0, getpid()) == -1 || ((*new)->pid = getpgrp(0)) == -1) {
          return errno;
      }
  #elif defined(OS2) || defined(TPF)
      /* OS/2 don't support process group IDs */
      (*new)->pid = getpid();
  #elif defined(MPE)
      /* MPE uses negative pid for process group */
       (*new)->pid = -getpid();
  #else
      if (((*new)->pid = setpgrp(getpid(), 0)) == -1) {
          return errno;
      }
  #endif
  
      /* close out the standard file descriptors */
      if (freopen("/dev/null", "r", stdin) == NULL) {
          return APR_ALLSTD;
          /* continue anyhow -- note we can't close out descriptor 0 because we
           * have nothing to replace it with, and if we didn't have a descriptor
           * 0 the next file would be created with that value ... leading to
           * havoc.
           */
      }
      if (freopen("/dev/null", "w", stdout) == NULL) {
          return APR_STDOUT;
      }
       /* We are going to reopen this again in a little while to the error
        * log file, but better to do it twice and suffer a small performance
        * hit for consistancy than not reopen it here.
        */
      if (freopen("/dev/null", "w", stderr) == NULL) {
          return APR_STDERR;
      }
  }
  
  
  
  
  
  1.19      +4 -0      apache-apr/include/apr_errno.h
  
  Index: apr_errno.h
  ===================================================================
  RCS file: /home/cvs/apache-apr/include/apr_errno.h,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- apr_errno.h	1999/06/10 12:15:38	1.18
  +++ apr_errno.h	1999/06/17 15:05:24	1.19
  @@ -401,6 +401,10 @@
   #define APR_CHILD_NOTDONE  5006
   #define APR_TIMEUP         5007
   #define APR_INVALSOCK      5008
  +#define APR_ALLSTD         5009
  +#define APR_STDOUT         5010
  +#define APR_STDERR         5011
  +
   #ifdef __cplusplus
   }
   #endif
  
  
  

Mime
View raw message