Mercurial > hg > nginx
comparison src/os/unix/ngx_posix_init.c @ 111:1c002f2b77ed
nginx-0.0.1-2003-07-03-20:30:22 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Thu, 03 Jul 2003 16:30:22 +0000 |
parents | 738fe44c70d5 |
children | 571bcbff82c5 |
comparison
equal
deleted
inserted
replaced
110:152567c11325 | 111:1c002f2b77ed |
---|---|
3 #include <ngx_core.h> | 3 #include <ngx_core.h> |
4 | 4 |
5 | 5 |
6 int ngx_max_sockets; | 6 int ngx_max_sockets; |
7 int ngx_inherited_nonblocking; | 7 int ngx_inherited_nonblocking; |
8 | |
9 | |
10 void ngx_restart_signal_handler(int signo); | |
11 void ngx_rotate_signal_handler(int signo); | |
8 | 12 |
9 | 13 |
10 int ngx_posix_init(ngx_log_t *log) | 14 int ngx_posix_init(ngx_log_t *log) |
11 { | 15 { |
12 struct sigaction sa; | 16 struct sigaction sa; |
13 struct rlimit rlmt; | 17 struct rlimit rlmt; |
14 | 18 |
15 ngx_memzero(&sa, sizeof(struct sigaction)); | 19 ngx_memzero(&sa, sizeof(struct sigaction)); |
16 sa.sa_handler = SIG_IGN; | 20 sa.sa_handler = SIG_IGN; |
17 sigemptyset(&sa.sa_mask); | 21 sigemptyset(&sa.sa_mask); |
18 | |
19 if (sigaction(SIGPIPE, &sa, NULL) == -1) { | 22 if (sigaction(SIGPIPE, &sa, NULL) == -1) { |
20 ngx_log_error(NGX_LOG_EMERG, log, ngx_errno, | 23 ngx_log_error(NGX_LOG_EMERG, log, ngx_errno, |
21 "sigaction(SIGPIPE, SIG_IGN) failed"); | 24 "sigaction(SIGPIPE, SIG_IGN) failed"); |
25 return NGX_ERROR; | |
26 } | |
27 | |
28 sa.sa_handler = ngx_restart_signal_handler; | |
29 if (sigaction(SIGHUP, &sa, NULL) == -1) { | |
30 ngx_log_error(NGX_LOG_EMERG, log, ngx_errno, | |
31 "sigaction(SIGHUP) failed"); | |
32 return NGX_ERROR; | |
33 } | |
34 | |
35 sa.sa_handler = ngx_rotate_signal_handler; | |
36 if (sigaction(SIGUSR1, &sa, NULL) == -1) { | |
37 ngx_log_error(NGX_LOG_EMERG, log, ngx_errno, | |
38 "sigaction(SIGUSR1) failed"); | |
22 return NGX_ERROR; | 39 return NGX_ERROR; |
23 } | 40 } |
24 | 41 |
25 | 42 |
26 if (getrlimit(RLIMIT_NOFILE, &rlmt) == -1) { | 43 if (getrlimit(RLIMIT_NOFILE, &rlmt) == -1) { |
43 | 60 |
44 return NGX_OK; | 61 return NGX_OK; |
45 } | 62 } |
46 | 63 |
47 | 64 |
65 void ngx_restart_signal_handler(int signo) | |
66 { | |
67 restart = 1; | |
68 } | |
69 | |
70 | |
71 void ngx_rotate_signal_handler(int signo) | |
72 { | |
73 rotate = 1; | |
74 } | |
75 | |
76 | |
48 int ngx_posix_post_conf_init(ngx_log_t *log) | 77 int ngx_posix_post_conf_init(ngx_log_t *log) |
49 { | 78 { |
50 ngx_fd_t pp[2]; | 79 ngx_fd_t pp[2]; |
51 | 80 |
52 if (pipe(pp) == -1) { | 81 if (pipe(pp) == -1) { |