Mercurial > hg > nginx
comparison src/os/unix/ngx_posix_init.c @ 226:b0c1e21e68db
nginx-0.0.1-2004-01-14-00:33:59 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Tue, 13 Jan 2004 21:33:59 +0000 |
parents | 2e9a8a14a0cf |
children | 86e473b5641e |
comparison
equal
deleted
inserted
replaced
225:2e9a8a14a0cf | 226:b0c1e21e68db |
---|---|
39 ngx_signal_handler }, | 39 ngx_signal_handler }, |
40 | 40 |
41 { ngx_signal_value(NGX_CHANGEBIN_SIGNAL), | 41 { ngx_signal_value(NGX_CHANGEBIN_SIGNAL), |
42 "SIG" ngx_value(NGX_CHANGEBIN_SIGNAL), | 42 "SIG" ngx_value(NGX_CHANGEBIN_SIGNAL), |
43 ngx_signal_handler }, | 43 ngx_signal_handler }, |
44 | |
45 { SIGINT, "SIGINT", ngx_signal_handler }, | |
44 | 46 |
45 { SIGCHLD, "SIGCHLD", ngx_signal_handler }, | 47 { SIGCHLD, "SIGCHLD", ngx_signal_handler }, |
46 | 48 |
47 { SIGPIPE, "SIGPIPE, SIG_IGN", SIG_IGN }, | 49 { SIGPIPE, "SIGPIPE, SIG_IGN", SIG_IGN }, |
48 | 50 |
91 | 93 |
92 void ngx_signal_handler(int signo) | 94 void ngx_signal_handler(int signo) |
93 { | 95 { |
94 char *action; | 96 char *action; |
95 struct timeval tv; | 97 struct timeval tv; |
98 ngx_int_t ignore; | |
96 ngx_err_t err; | 99 ngx_err_t err; |
97 ngx_signal_t *sig; | 100 ngx_signal_t *sig; |
98 | 101 |
99 ngx_signal = 1; | 102 ngx_signal = 1; |
103 ignore = 0; | |
100 | 104 |
101 err = ngx_errno; | 105 err = ngx_errno; |
102 | 106 |
103 for (sig = signals; sig->signo != 0; sig++) { | 107 for (sig = signals; sig->signo != 0; sig++) { |
104 if (sig->signo == signo) { | 108 if (sig->signo == signo) { |
136 ngx_reconfigure = 1; | 140 ngx_reconfigure = 1; |
137 action = ", reconfiguring"; | 141 action = ", reconfiguring"; |
138 break; | 142 break; |
139 | 143 |
140 case ngx_signal_value(NGX_REOPEN_SIGNAL): | 144 case ngx_signal_value(NGX_REOPEN_SIGNAL): |
141 ngx_reopen = 1; | 145 if (ngx_noaccept) { |
142 action = ", reopen logs"; | 146 action = ", ignoring"; |
143 break; | 147 |
148 } else { | |
149 ngx_reopen = 1; | |
150 action = ", reopen logs"; | |
151 break; | |
152 } | |
144 | 153 |
145 case ngx_signal_value(NGX_CHANGEBIN_SIGNAL): | 154 case ngx_signal_value(NGX_CHANGEBIN_SIGNAL): |
155 if ((ngx_inherited && getppid() > 1) | |
156 || (!ngx_inherited && ngx_new_binary > 0)) | |
157 { | |
158 /* | |
159 * Ignore the signal in the new binary if its parent is | |
160 * not the init process, i.e. the old binary's process | |
161 * is still running. Or ingore the signal in the old binary's | |
162 * process if the new binary's process is already running. | |
163 */ | |
164 | |
165 action = ", ignoring"; | |
166 ignore = 1; | |
167 break; | |
168 } | |
169 | |
146 ngx_change_binary = 1; | 170 ngx_change_binary = 1; |
147 action = ", changing binary"; | 171 action = ", changing binary"; |
148 break; | 172 break; |
149 | 173 |
150 case SIGCHLD: | 174 case SIGCHLD: |
187 } | 211 } |
188 | 212 |
189 ngx_log_error(NGX_LOG_INFO, ngx_cycle->log, 0, | 213 ngx_log_error(NGX_LOG_INFO, ngx_cycle->log, 0, |
190 "signal %d (%s) received%s", signo, sig->signame, action); | 214 "signal %d (%s) received%s", signo, sig->signame, action); |
191 | 215 |
216 if (ignore) { | |
217 ngx_log_error(NGX_LOG_CRIT, ngx_cycle->log, 0, | |
218 "the changing binary signal is ignored: " | |
219 "you should shutdown or terminate " | |
220 "before either old or new binary's process"); | |
221 } | |
222 | |
192 if (signo == SIGCHLD) { | 223 if (signo == SIGCHLD) { |
193 ngx_process_get_status(); | 224 ngx_process_get_status(); |
194 } | 225 } |
195 | 226 |
196 ngx_set_errno(err); | 227 ngx_set_errno(err); |