You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by Mark Cox <mj...@hyperreal.com> on 1996/04/15 13:34:53 UTC

cvs commit: apache/src http_log.c

mjc         96/04/15 04:34:53

  Modified:    src       http_log.c
  Log:
  Submitted by: James H. Cloos Jr. <cl...@jhcloos.com>
  
  Allow ErrorLogs to be pipes.
  
  Revision  Changes    Path
  1.4       +30 -4     apache/src/http_log.c
  
  Index: http_log.c
  ===================================================================
  RCS file: /export/home/cvs/apache/src/http_log.c,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -C3 -r1.3 -r1.4
  *** http_log.c	1996/03/01 02:39:49	1.3
  --- http_log.c	1996/04/15 11:34:52	1.4
  ***************
  *** 67,81 ****
    
    #include <stdarg.h>
    
    void open_error_log(server_rec *s, pool *p)
    {
        char *fname;
      
        fname = server_root_relative (p, s->error_fname);
  !     if(!(s->error_log = pfopen(p, fname, "a"))) {
  !         fprintf(stderr,"httpd: could not open error log file %s.\n", fname);
  !         perror("fopen");
  !         exit(1);
        }
    }
    
  --- 67,107 ----
    
    #include <stdarg.h>
    
  + void error_log_child (void *cmd)
  + {
  +     /* Child process code for 'ErrorLog "|..."';
  +      * may want a common framework for this, since I expect it will
  +      * be common for other foo-loggers to want this sort of thing...
  +      */
  +     
  +     cleanup_for_exec();
  +     signal (SIGHUP, SIG_IGN);
  +     execl (SHELL_PATH, SHELL_PATH, "-c", (char *)cmd, NULL);
  +     exit (1);
  + }
  + 
    void open_error_log(server_rec *s, pool *p)
    {
        char *fname;
      
        fname = server_root_relative (p, s->error_fname);
  ! 
  !     if (*fname == '|') {
  !       FILE *dummy;
  ! 
  !       spawn_child(p, error_log_child, (void *)(fname+1),
  !                     kill_after_timeout, &dummy, NULL);
  ! 
  !         if (dummy == NULL) {
  !             fprintf (stderr, "Couldn't fork child for ErrorLog process\n");
  !             exit (1);
  !       }
  !     } else {
  !         if(!(s->error_log = pfopen(p, fname, "a"))) {
  !             fprintf(stderr,"httpd: could not open error log file %s.\n", fname);
  !             perror("fopen");
  !             exit(1);
  !       }
        }
    }