]> git.kaiwu.me - nginx.git/commitdiff
Core: fixed stderr redirection on win32 in ngx_reopen_files().
authorVladimir Homutov <vl@nginx.com>
Mon, 3 Jun 2013 12:54:28 +0000 (16:54 +0400)
committerVladimir Homutov <vl@nginx.com>
Mon, 3 Jun 2013 12:54:28 +0000 (16:54 +0400)
On win32 stderr was not redirected into a file specified by "error_log"
while reopening files.  Fix is to use platform-independent functions to
work with stderr, as already used by ngx_init_cycle() and main() since
rev. d8316f307b6a.

src/core/ngx_cycle.c

index 87b6d7daa0c051d82634d09fa966ac8d189fc54a..40b8562b4f4708337b3e4ab7561ed3672289b036 100644 (file)
@@ -1228,16 +1228,13 @@ ngx_reopen_files(ngx_cycle_t *cycle, ngx_uid_t user)
         file[i].fd = fd;
     }
 
-#if !(NGX_WIN32)
+    if (cycle->log->file->fd != ngx_stderr) {
 
-    if (cycle->log->file->fd != STDERR_FILENO) {
-        if (dup2(cycle->log->file->fd, STDERR_FILENO) == -1) {
-            ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
-                          "dup2(STDERR) failed");
+        if (ngx_set_stderr(cycle->log->file->fd) == NGX_FILE_ERROR) {
+            ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
+                          ngx_set_stderr_n " failed");
         }
     }
-
-#endif
 }