160
162
WaitForSingleObject(stderr_ready, INFINITE);
162
/* Flush stderr and unset its buffer, then commit and replace stderr.
163
* This is typically a noop for Win2K/XP since services with NULL std
164
* handles [but valid FILE *'s, oddly enough], but is required
165
* for NT 4.0 and to use this code outside of services.
168
setvbuf(stderr, NULL, _IONBF, 0);
169
_commit(2 /* stderr */);
170
fd = _open_osfhandle((long) hPipeWrite,
171
_O_WRONLY | _O_BINARY);
174
_setmode(2, _O_BINARY);
176
/* hPipeWrite was _close()'ed above, and _dup2()'ed
177
* to fd 2 creating a new, inherited Win32 handle.
178
* Recover that real handle from fd 2.
180
hPipeWrite = (HANDLE)_get_osfhandle(2);
182
SetStdHandle(STD_ERROR_HANDLE, hPipeWrite);
164
if ((apr_file_open_stderr(&stderr_file, p)
166
&& (apr_os_file_put(&eventlog_file, &hPipeWrite, APR_WRITE, p)
168
apr_file_dup2(stderr_file, eventlog_file, p);
184
170
/* The code above _will_ corrupt the StdHandle...
185
171
* and we must do so anyways. We set this up only