From: William A. Rowe Jr Date: Sun, 6 Jan 2008 17:35:03 +0000 (+0000) Subject: Resolve console-mode stdout file descriptor issues for mod_perl by replacing X-Git-Tag: 2.3.0~1055 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1185659d69caf992c20e3be34aa4e3067600716b;p=apache Resolve console-mode stdout file descriptor issues for mod_perl by replacing it in lockstep with unix stdout replacement (in pre_config). Only an undetached server (console mode single process/debug) will retain the original stdout, just as on unix. Inspired by research of Tom and myself (CHANGES to credit both). PR: 43534 git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@609354 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/server/mpm/winnt/mpm_winnt.c b/server/mpm/winnt/mpm_winnt.c index e61d66fd98..9ce90fbff5 100644 --- a/server/mpm/winnt/mpm_winnt.c +++ b/server/mpm/winnt/mpm_winnt.c @@ -1372,6 +1372,24 @@ static int winnt_pre_config(apr_pool_t *pconf_, apr_pool_t *plog, apr_pool_t *pt service_name); exit(APEXIT_INIT); } + else if (!one_process) { + /* Open a null handle to soak stdout in this process. + * We need to emulate apr_proc_detach, unix performs this + * same check in the pre_config hook (although it is + * arguably premature). Services already fixed this. + */ + apr_file_t *nullfile; + + if ((rv = apr_file_open(&nullfile, "NUL", + APR_READ | APR_WRITE, APR_OS_DEFAULT, + process->pool)) == APR_SUCCESS) { + apr_file_t *nullstdout; + if (apr_file_open_stdout(&nullstdout, process->pool) + == APR_SUCCESS) + apr_file_dup2(nullstdout, nullfile, process->pool); + apr_file_close(nullfile); + } + } /* Win9x: disable AcceptEx */ if (osver.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) {