~ubuntu-branches/ubuntu/hardy/apache2/hardy-proposed

« back to all changes in this revision

Viewing changes to server/mpm/winnt/nt_eventlog.c

  • Committer: Bazaar Package Importer
  • Author(s): Stefan Fritsch
  • Date: 2008-01-17 20:27:56 UTC
  • mto: This revision was merged to the branch mainline in revision 26.
  • Revision ID: james.westby@ubuntu.com-20080117202756-hv38rjknhwa2ilwi
Tags: upstream-2.2.8
ImportĀ upstreamĀ versionĀ 2.2.8

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
#include "mpm_winnt.h"
22
22
#include "apr_strings.h"
23
23
#include "apr_lib.h"
 
24
#include "apr_portable.h"
24
25
#include "ap_regkey.h"
25
26
 
26
27
static char  *display_name  = NULL;
138
139
    HANDLE hPipeWrite = NULL;
139
140
    HANDLE hDup = NULL;
140
141
    DWORD  threadid;
141
 
    int    fd;
 
142
    apr_file_t *eventlog_file;
 
143
    apr_file_t *stderr_file;
142
144
 
143
145
    display_name = argv0;
144
146
 
159
161
 
160
162
    WaitForSingleObject(stderr_ready, INFINITE);
161
163
 
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.
166
 
     */
167
 
    fflush(stderr);
168
 
    setvbuf(stderr, NULL, _IONBF, 0);
169
 
    _commit(2 /* stderr */);
170
 
    fd = _open_osfhandle((long) hPipeWrite,
171
 
                         _O_WRONLY | _O_BINARY);
172
 
    _dup2(fd, 2);
173
 
    _close(fd);
174
 
    _setmode(2, _O_BINARY);
175
 
 
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.
179
 
     */
180
 
    hPipeWrite = (HANDLE)_get_osfhandle(2);
181
 
 
182
 
    SetStdHandle(STD_ERROR_HANDLE, hPipeWrite);
 
164
    if ((apr_file_open_stderr(&stderr_file, p) 
 
165
             == APR_SUCCESS)
 
166
     && (apr_os_file_put(&eventlog_file, &hPipeWrite, APR_WRITE, p)
 
167
             == APR_SUCCESS))
 
168
        apr_file_dup2(stderr_file, eventlog_file, p);
183
169
 
184
170
    /* The code above _will_ corrupt the StdHandle...
185
171
     * and we must do so anyways.  We set this up only