Mercurial > hg > nginx-vendor-current
annotate src/os/unix/ngx_daemon.c @ 634:23ef0645ea57 NGINX_1_1_1
nginx 1.1.1
*) Change: now cache loader processes either as many files as specified
by "loader_files" parameter or works no more than time specified by
"loader_threshold" parameter during each iteration.
*) Change: now SIGWINCH signal works only in deamon mode.
*) Feature: now shared zones and caches use POSIX semaphores on
Solaris.
Thanks to Den Ivanov.
*) Feature: accept filters are now supported on NetBSD.
*) Bugfix: nginx could not be build on Linux 3.0.
*) Bugfix: nginx did not use gzipping in some cases; the bug had
appeared in 1.1.0.
*) Bugfix: request body might be incorrectly processed if client used
pipelining.
*) Bugfix: in the "request_body_in_single_buf" directive.
*) Bugfix: in "proxy_set_body" and "proxy_pass_request_body" directives
if SSL connection to backend was used.
*) Bugfix: nginx hogged CPU if all servers in an upstream were marked
as "down".
*) Bugfix: a segmentation fault might occur during reconfiguration if
ssl_session_cache was defined but not used in a previous
configuration.
*) Bugfix: a segmentation fault might occur in a worker process if many
backup servers were used in an upstream.
*) Bugfix: a segmentation fault might occur in a worker process if
"fastcgi/scgi/uwsgi_param" directives were used with values starting
with "HTTP_"; the bug had appeared in 0.8.40.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Mon, 22 Aug 2011 00:00:00 +0400 |
parents | 6cfc63e68377 |
children | d0f7a625f27c |
rev | line source |
---|---|
0 | 1 |
2 /* | |
3 * Copyright (C) Igor Sysoev | |
4 */ | |
5 | |
6 | |
7 #include <ngx_config.h> | |
8 #include <ngx_core.h> | |
9 | |
10 | |
48 | 11 ngx_int_t ngx_daemon(ngx_log_t *log) |
0 | 12 { |
13 int fd; | |
14 | |
15 switch (fork()) { | |
16 case -1: | |
17 ngx_log_error(NGX_LOG_EMERG, log, ngx_errno, "fork() failed"); | |
18 return NGX_ERROR; | |
19 | |
20 case 0: | |
21 break; | |
22 | |
23 default: | |
24 exit(0); | |
25 } | |
26 | |
27 ngx_pid = ngx_getpid(); | |
28 | |
29 if (setsid() == -1) { | |
30 ngx_log_error(NGX_LOG_EMERG, log, ngx_errno, "setsid() failed"); | |
31 return NGX_ERROR; | |
32 } | |
33 | |
34 umask(0); | |
35 | |
36 fd = open("/dev/null", O_RDWR); | |
37 if (fd == -1) { | |
38 ngx_log_error(NGX_LOG_EMERG, log, ngx_errno, | |
39 "open(\"/dev/null\") failed"); | |
40 return NGX_ERROR; | |
41 } | |
42 | |
43 if (dup2(fd, STDIN_FILENO) == -1) { | |
44 ngx_log_error(NGX_LOG_EMERG, log, ngx_errno, "dup2(STDIN) failed"); | |
45 return NGX_ERROR; | |
46 } | |
47 | |
48 if (dup2(fd, STDOUT_FILENO) == -1) { | |
49 ngx_log_error(NGX_LOG_EMERG, log, ngx_errno, "dup2(STDOUT) failed"); | |
50 return NGX_ERROR; | |
51 } | |
52 | |
53 #if 0 | |
54 if (dup2(fd, STDERR_FILENO) == -1) { | |
55 ngx_log_error(NGX_LOG_EMERG, log, ngx_errno, "dup2(STDERR) failed"); | |
56 return NGX_ERROR; | |
57 } | |
58 #endif | |
59 | |
60 if (fd > STDERR_FILENO) { | |
61 if (close(fd) == -1) { | |
62 ngx_log_error(NGX_LOG_EMERG, log, ngx_errno, "close() failed"); | |
63 return NGX_ERROR; | |
64 } | |
65 } | |
66 | |
67 return NGX_OK; | |
68 } |