nginx-0.0.1-2003-07-10-20:26:57 import
diff --git a/src/core/nginx.c b/src/core/nginx.c
index 1de6e32..fd2f2db 100644
--- a/src/core/nginx.c
+++ b/src/core/nginx.c
@@ -61,7 +61,20 @@
ngx_cycle = cycle;
- /* daemon */
+#if !(WIN32)
+
+ if (0) {
+ if (ngx_daemon(cycle->log) == NGX_ERROR) {
+ return 1;
+ }
+ }
+
+ if (dup2(cycle->log->file->fd, STDERR_FILENO) == -1) {
+ ngx_log_error(NGX_LOG_EMERG, log, ngx_errno, "dup2(STDERR) failed");
+ return 1;
+ }
+
+#endif
/* life cycle */
@@ -154,7 +167,7 @@
cycle->open_files.nalloc = n;
cycle->open_files.pool = pool;
- cycle->log = ngx_log_create_errlog(cycle);
+ cycle->log = ngx_log_create_errlog(cycle, NULL);
if (cycle->log == NULL) {
ngx_destroy_pool(pool);
return NULL;
diff --git a/src/core/ngx_core.h b/src/core/ngx_core.h
index 879dad3..1b885c6 100644
--- a/src/core/ngx_core.h
+++ b/src/core/ngx_core.h
@@ -18,9 +18,9 @@
typedef struct ngx_event_s ngx_event_t;
typedef struct ngx_connection_s ngx_connection_t;
+#include <ngx_string.h>
#include <ngx_log.h>
#include <ngx_alloc.h>
-#include <ngx_string.h>
#include <ngx_hunk.h>
#include <ngx_array.h>
#include <ngx_table.h>
diff --git a/src/core/ngx_log.c b/src/core/ngx_log.c
index 2f8276b..c3cec38 100644
--- a/src/core/ngx_log.c
+++ b/src/core/ngx_log.c
@@ -240,13 +240,16 @@
}
-ngx_log_t *ngx_log_create_errlog(ngx_cycle_t *cycle)
+ngx_log_t *ngx_log_create_errlog(ngx_cycle_t *cycle, ngx_str_t *name)
{
ngx_log_t *log;
ngx_test_null(log, ngx_pcalloc(cycle->pool, sizeof(ngx_log_t)), NULL);
ngx_test_null(log->file, ngx_push_array(&cycle->open_files), NULL);
log->file->fd = NGX_INVALID_FILE;
+ if (name) {
+ log->file->name = *name;
+ }
return log;
}
diff --git a/src/core/ngx_log.h b/src/core/ngx_log.h
index f180272..dcbbef8 100644
--- a/src/core/ngx_log.h
+++ b/src/core/ngx_log.h
@@ -168,7 +168,7 @@
#define ngx_log_copy_log(new, old) ngx_memcpy(new, old, sizeof(ngx_log_t))
ngx_log_t *ngx_log_init_errlog();
-ngx_log_t *ngx_log_create_errlog(ngx_cycle_t *cycle);
+ngx_log_t *ngx_log_create_errlog(ngx_cycle_t *cycle, ngx_str_t *name);
extern ngx_module_t ngx_errlog_module;
diff --git a/src/core/ngx_os_init.h b/src/core/ngx_os_init.h
index 18e7574..e10a07d 100644
--- a/src/core/ngx_os_init.h
+++ b/src/core/ngx_os_init.h
@@ -34,6 +34,10 @@
int ngx_os_init(ngx_log_t *log);
+#if !(WIN32)
+int ngx_daemon(ngx_log_t *log);
+#endif
+
extern ngx_os_io_t ngx_os_io;
extern int ngx_max_sockets;