From: William A. Rowe Jr Date: Tue, 12 Feb 2002 00:11:34 +0000 (+0000) Subject: This code seriously misassumed (and may yet) that stderr was a valid file. X-Git-Tag: 2.0.33~299 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=67d6dd0743c78df4ac3e68270e36361fa9380bc5;p=apache This code seriously misassumed (and may yet) that stderr was a valid file. 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 --- diff --git a/server/log.c b/server/log.c index b2cf12163d..b339b8ba11 100644 --- a/server/log.c +++ b/server/log.c @@ -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,