Index: server/mpm/winnt/mpm_winnt.c =================================================================== --- server/mpm/winnt/mpm_winnt.c (revision 603073) +++ server/mpm/winnt/mpm_winnt.c (working copy) @@ -625,6 +625,7 @@ apr_pool_t *ptemp; apr_procattr_t *attr; apr_proc_t new_child; + apr_file_t *tmp_stdout; HANDLE hExitEvent; HANDLE waitlist[2]; /* see waitlist_e */ char *cmd; @@ -678,6 +679,12 @@ return -1; } + /* Always pass a "NUL" stdout to child process */ + if (apr_file_open(&tmp_stdout, "NUL", APR_READ | APR_WRITE, APR_OS_DEFAULT, ptemp) + || apr_procattr_child_out_set(attr, tmp_stdout, NULL) ) + ap_log_error(APLOG_MARK, APLOG_CRIT, rv, ap_server_conf, + "Parent: Unable to pass NUL stdout to child."); + /* Create the child_ready_event */ waitlist[waitlist_ready] = CreateEvent(NULL, TRUE, FALSE, NULL); if (!waitlist[waitlist_ready]) { @@ -713,6 +720,8 @@ env[envc + 1] = NULL; } + apr_file_close(tmp_stdout); + rv = apr_proc_create(&new_child, cmd, args, env, attr, ptemp); if (rv != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_CRIT, rv, ap_server_conf, @@ -1267,8 +1276,6 @@ */ if (osver.dwPlatformId == VER_PLATFORM_WIN32_NT) { - apr_file_t *nullfile; - if (!errout) { mpm_nt_eventlog_stderr_open(service_name, process->pool); } @@ -1277,30 +1284,6 @@ if (service_to_start_success == APR_SUCCESS) { service_set = APR_SUCCESS; } - - /* Open a null handle to soak stdout in this process. - * Windows service processes are missing any file handle - * usable for stdin/out/err. This was the cause of later - * trouble with invocations of apr_file_open_stdout() - */ - if ((rv = apr_file_open(&nullfile, "NUL", - APR_READ | APR_WRITE, APR_OS_DEFAULT, - process->pool)) == APR_SUCCESS) { - HANDLE hproc = GetCurrentProcess(); - HANDLE nullstdout = NULL; - HANDLE nullhandle; - - /* Duplicate the handle to be inherited by children */ - if ((apr_os_file_get(&nullhandle, nullfile) == APR_SUCCESS) - && DuplicateHandle(hproc, nullhandle, - hproc, &nullstdout, - 0, TRUE, DUPLICATE_SAME_ACCESS)) { - SetStdHandle(STD_OUTPUT_HANDLE, nullstdout); - } - - /* Close the original handle, we used the duplicate */ - apr_file_close(nullfile); - } } } @@ -1639,9 +1622,12 @@ /* Set up the listeners */ get_listeners_from_parent(s); - /* Done reading from the parent, close that channel */ - CloseHandle(pipe); - + /* Dup the NUL stdout for modules which expect a valid Unix-like stdin + * fd to exist (e.g. mod_perl). Not necessary in single process mode. + * This implicitly closes the pipe handle (STD_INPUT_HANDLE) + */ + _dup2(_fileno(stdout), _fileno(stdin)); + ap_my_generation = ap_scoreboard_image->global->running_generation; } else {