]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
httpd-2.2 and -2.0 specific patch to revert to 2.0.55/2.2.0 handling of the
authorWilliam A. Rowe Jr <wrowe@apache.org>
Thu, 5 Jun 2008 19:11:51 +0000 (19:11 +0000)
committerWilliam A. Rowe Jr <wrowe@apache.org>
Thu, 5 Jun 2008 19:11:51 +0000 (19:11 +0000)
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
Backports: r663704

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.0.x@663705 13f79535-47bb-0310-9956-ffa450edef68

server/mpm/winnt/mpm_winnt.c

index c766f44416f56e25db64e345f81c3b942c60e496..6fc0ae60c8914c1939807df5289ecba807cca06c 100644 (file)
@@ -680,7 +680,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)) {
@@ -734,7 +735,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);
 
@@ -1400,26 +1401,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) {