From: William A. Rowe Jr Date: Thu, 5 Jun 2008 19:11:27 +0000 (+0000) Subject: httpd-2.2 and -2.0 specific patch to revert to 2.0.55/2.2.0 handling of the X-Git-Tag: 2.2.9~26 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a41ca03cd6feaa25784c0fc9c12df2920f68bc61;p=thirdparty%2Fapache%2Fhttpd.git httpd-2.2 and -2.0 specific patch to revert to 2.0.55/2.2.0 handling of the stdout channel; do not close stdout in the parent process or reassign it to \\Device\Null, but keep it open so that the console signal handler continues to interact with the running "daemonized" httpd process. Not committed to httpd-2.x; there is disagreement as to whether this is good behavior for a daemon, and the proper 2.4(3.0) behavior on Win32 may be to daemonize but properly handle -k stop by the PID file contents. Many have asked for this feature who run a minimal httpd.exe, especially from some removeable media such as CD, and wish to be able to halt it as a console. PR: 44800 (part 3/3) Submitted by: tdonovan git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.2.x@663704 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/server/mpm/winnt/mpm_winnt.c b/server/mpm/winnt/mpm_winnt.c index f1fc2f287a5..52c4ff9ccc3 100644 --- a/server/mpm/winnt/mpm_winnt.c +++ b/server/mpm/winnt/mpm_winnt.c @@ -681,7 +681,8 @@ static int create_process(apr_pool_t *p, HANDLE *child_proc, HANDLE *child_exit_ } /* httpd-2.0/2.2 specific to work around apr_proc_create bugs */ - if (((rv = apr_file_open_stdout(&child_out, p)) + /* set "NUL" as sysout for the child */ + if (((rv = apr_file_open(&child_out, "NUL", APR_WRITE | APR_READ, APR_OS_DEFAULT,p)) != APR_SUCCESS) || ((rv = apr_procattr_child_out_set(attr, child_out, NULL)) != APR_SUCCESS)) { @@ -735,7 +736,7 @@ static int create_process(apr_pool_t *p, HANDLE *child_proc, HANDLE *child_exit_ CloseHandle(new_child.hproc); return -1; } - + apr_file_close(child_out); ap_log_error(APLOG_MARK, APLOG_NOTICE, APR_SUCCESS, ap_server_conf, "Parent: Created child process %d", new_child.pid); @@ -1430,26 +1431,6 @@ 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 && !ap_my_generation) { - /* 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; - apr_status_t rv; - apr_pool_t *pproc = apr_pool_parent_get(pconf); - - if ((rv = apr_file_open(&nullfile, "NUL", - APR_READ | APR_WRITE, APR_OS_DEFAULT, - pproc)) == APR_SUCCESS) { - apr_file_t *nullstdout; - if (apr_file_open_stdout(&nullstdout, pproc) - == APR_SUCCESS) - apr_file_dup2(nullstdout, nullfile, pproc); - apr_file_close(nullfile); - } - } /* Win9x: disable AcceptEx */ if (osver.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) {