Mercurial > hg > nginx-vendor-current
annotate src/os/unix/ngx_daemon.c @ 566:be4f34123024 NGINX_0_8_35
nginx 0.8.35
*) Change: now the charset filter runs before the SSI filter.
*) Feature: the "chunked_transfer_encoding" directive.
*) Bugfix: an "&" character was not escaped when it was copied in
arguments part in a rewrite rule.
*) Bugfix: nginx might be terminated abnormally while a signal
processing or if the directive "timer_resolution" was used on
platforms which do not support kqueue or eventport notification
methods.
Thanks to George Xie and Maxim Dounin.
*) Bugfix: if temporary files and permanent storage area resided at
different file systems, then permanent file modification times were
incorrect.
Thanks to Maxim Dounin.
*) Bugfix: ngx_http_memcached_module might issue the error message
"memcached sent invalid trailer".
Thanks to Maxim Dounin.
*) Bugfix: nginx could not built zlib-1.2.4 library using the library
sources.
Thanks to Maxim Dounin.
*) Bugfix: a segmentation fault occurred in a worker process, if there
was large stderr output before FastCGI response; the bug had
appeared in 0.8.34.
Thanks to Maxim Dounin.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Mon, 29 Mar 2010 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 } |