]> granicus.if.org Git - apache/commitdiff
This code seriously misassumed (and may yet) that stderr was a valid file.
authorWilliam A. Rowe Jr <wrowe@apache.org>
Tue, 12 Feb 2002 00:11:34 +0000 (00:11 +0000)
committerWilliam A. Rowe Jr <wrowe@apache.org>
Tue, 12 Feb 2002 00:11:34 +0000 (00:11 +0000)
  It also has some bogus non-apr code that probably does great evil to win32
  services.  This must be bumped into .32, code review is incomplete still.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@93368 13f79535-47bb-0310-9956-ffa450edef68

server/log.c

index b2cf12163de9268a400689c565c13f77ad078aa3..b339b8ba11148baf9b359d2fd7df27c35dad0bb9 100644 (file)
@@ -179,7 +179,7 @@ static const TRANS priorities[] = {
     {NULL,      -1},
 };
 
-static apr_file_t *stderr_log;
+static apr_file_t *stderr_log = NULL;
 
 AP_DECLARE(void) ap_open_stderr_log(apr_pool_t *p)
 {
@@ -294,8 +294,9 @@ void ap_open_logs(server_rec *s_main, apr_pool_t *p)
     if (s_main->error_log) {
         /* replace stderr with this new log */
         apr_file_flush(s_main->error_log);
-        apr_file_open_stderr(&errfile, p);        
-        rc = apr_file_dup2(errfile, s_main->error_log, p);
+        if ((rc = apr_file_open_stderr(&errfile, p)) == APR_SUCCESS) {
+            rc = apr_file_dup2(errfile, s_main->error_log, p);
+        }
         if (rc != APR_SUCCESS) {
             ap_log_error(APLOG_MARK, APLOG_CRIT, rc, s_main,
                          "unable to replace stderr with error_log");
@@ -306,6 +307,7 @@ void ap_open_logs(server_rec *s_main, apr_pool_t *p)
     /* note that stderr may still need to be replaced with something
      * because it points to the old error log, or back to the tty
      * of the submitter.
+     * XXX: This is BS - /dev/null is non-portable
      */
     if (replace_stderr && freopen("/dev/null", "w", stderr) == NULL) {
         ap_log_error(APLOG_MARK, APLOG_CRIT, errno, s_main,