diff options
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/nginx.c | 17 | ||||
| -rw-r--r-- | src/core/ngx_core.h | 2 | ||||
| -rw-r--r-- | src/core/ngx_log.c | 5 | ||||
| -rw-r--r-- | src/core/ngx_log.h | 2 | ||||
| -rw-r--r-- | src/core/ngx_os_init.h | 4 |
5 files changed, 25 insertions, 5 deletions
diff --git a/src/core/nginx.c b/src/core/nginx.c index 1de6e3258..fd2f2db03 100644 --- a/src/core/nginx.c +++ b/src/core/nginx.c @@ -61,7 +61,20 @@ int main(int argc, char *const *argv) 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 @@ static ngx_cycle_t *ngx_init_cycle(ngx_cycle_t *old_cycle, ngx_log_t *log) 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 879dad357..1b885c653 100644 --- a/src/core/ngx_core.h +++ b/src/core/ngx_core.h @@ -18,9 +18,9 @@ typedef struct ngx_file_s ngx_file_t; 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 2f8276bb6..c3cec3862 100644 --- a/src/core/ngx_log.c +++ b/src/core/ngx_log.c @@ -240,13 +240,16 @@ 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) { 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 f18027277..dcbbef831 100644 --- a/src/core/ngx_log.h +++ b/src/core/ngx_log.h @@ -168,7 +168,7 @@ void ngx_assert_core(ngx_log_t *log, const char *fmt, ...); #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 18e757472..e10a07de6 100644 --- a/src/core/ngx_os_init.h +++ b/src/core/ngx_os_init.h @@ -34,6 +34,10 @@ typedef struct { 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; |
