Mercurial > hg > nginx
comparison src/os/unix/ngx_posix_init.c @ 93:738fe44c70d5
nginx-0.0.1-2003-05-21-17:28:21 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Wed, 21 May 2003 13:28:21 +0000 |
parents | |
children | 1c002f2b77ed |
comparison
equal
deleted
inserted
replaced
92:19cc647ecd91 | 93:738fe44c70d5 |
---|---|
1 | |
2 #include <ngx_config.h> | |
3 #include <ngx_core.h> | |
4 | |
5 | |
6 int ngx_max_sockets; | |
7 int ngx_inherited_nonblocking; | |
8 | |
9 | |
10 int ngx_posix_init(ngx_log_t *log) | |
11 { | |
12 struct sigaction sa; | |
13 struct rlimit rlmt; | |
14 | |
15 ngx_memzero(&sa, sizeof(struct sigaction)); | |
16 sa.sa_handler = SIG_IGN; | |
17 sigemptyset(&sa.sa_mask); | |
18 | |
19 if (sigaction(SIGPIPE, &sa, NULL) == -1) { | |
20 ngx_log_error(NGX_LOG_EMERG, log, ngx_errno, | |
21 "sigaction(SIGPIPE, SIG_IGN) failed"); | |
22 return NGX_ERROR; | |
23 } | |
24 | |
25 | |
26 if (getrlimit(RLIMIT_NOFILE, &rlmt) == -1) { | |
27 ngx_log_error(NGX_LOG_ALERT, log, errno, | |
28 "getrlimit(RLIMIT_NOFILE) failed)"); | |
29 return NGX_ERROR; | |
30 } | |
31 | |
32 ngx_log_error(NGX_LOG_INFO, log, 0, | |
33 "getrlimit(RLIMIT_NOFILE): %qd:%qd", | |
34 rlmt.rlim_cur, rlmt.rlim_max); | |
35 | |
36 ngx_max_sockets = rlmt.rlim_cur; | |
37 | |
38 #if (HAVE_INHERITED_NONBLOCK) | |
39 ngx_inherited_nonblocking = 1; | |
40 #else | |
41 ngx_inherited_nonblocking = 0; | |
42 #endif | |
43 | |
44 return NGX_OK; | |
45 } | |
46 | |
47 | |
48 int ngx_posix_post_conf_init(ngx_log_t *log) | |
49 { | |
50 ngx_fd_t pp[2]; | |
51 | |
52 if (pipe(pp) == -1) { | |
53 ngx_log_error(NGX_LOG_EMERG, log, ngx_errno, "pipe() failed"); | |
54 return NGX_ERROR; | |
55 } | |
56 | |
57 if (dup2(pp[1], STDERR_FILENO) == -1) { | |
58 ngx_log_error(NGX_LOG_EMERG, log, errno, "dup2(STDERR) failed"); | |
59 return NGX_ERROR; | |
60 } | |
61 | |
62 if (pp[1] > STDERR_FILENO) { | |
63 if (close(pp[1]) == -1) { | |
64 ngx_log_error(NGX_LOG_EMERG, log, errno, "close() failed"); | |
65 return NGX_ERROR; | |
66 } | |
67 } | |
68 | |
69 return NGX_OK; | |
70 } |