Mercurial > hg > nginx
comparison src/os/unix/ngx_process.c @ 389:537de4dca8ca
nginx-0.0.7-2004-07-13-21:59:12 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Tue, 13 Jul 2004 17:59:12 +0000 |
parents | e411b1482ee3 |
children | b670db10cbbd |
comparison
equal
deleted
inserted
replaced
388:80e72c428b39 | 389:537de4dca8ca |
---|---|
18 { | 18 { |
19 u_long on; | 19 u_long on; |
20 ngx_pid_t pid; | 20 ngx_pid_t pid; |
21 ngx_int_t s; | 21 ngx_int_t s; |
22 | 22 |
23 s = respawn >= 0 ? respawn : ngx_last_process; | 23 if (respawn >= 0) { |
24 s = respawn; | |
25 | |
26 } else { | |
27 for (s = 0; s < ngx_last_process; s++) { | |
28 if (ngx_processes[s].pid == -1) { | |
29 break; | |
30 } | |
31 } | |
32 | |
33 if (s == NGX_MAX_PROCESSES) { | |
34 ngx_log_error(NGX_LOG_ALERT, cycle->log, 0, | |
35 "no more than %d processes can be spawned", | |
36 NGX_MAX_PROCESSES); | |
37 return NGX_ERROR; | |
38 } | |
39 } | |
24 | 40 |
25 | 41 |
26 if (respawn != NGX_PROCESS_DETACHED) { | 42 if (respawn != NGX_PROCESS_DETACHED) { |
27 | 43 |
28 /* Solaris 9 still has no AF_LOCAL */ | 44 /* Solaris 9 still has no AF_LOCAL */ |
144 ngx_processes[s].just_respawn = 0; | 160 ngx_processes[s].just_respawn = 0; |
145 ngx_processes[s].detached = 1; | 161 ngx_processes[s].detached = 1; |
146 break; | 162 break; |
147 } | 163 } |
148 | 164 |
149 ngx_last_process++; | 165 if (s == ngx_last_process) { |
166 ngx_last_process++; | |
167 } | |
150 | 168 |
151 return pid; | 169 return pid; |
152 } | 170 } |
153 | 171 |
154 | 172 |
218 ngx_atomic_cmp_set(ngx_accept_mutex_ptr, pid, 0); | 236 ngx_atomic_cmp_set(ngx_accept_mutex_ptr, pid, 0); |
219 } | 237 } |
220 | 238 |
221 | 239 |
222 one = 1; | 240 one = 1; |
223 process = ""; | 241 process = "unknown process"; |
224 | 242 |
225 for (i = 0; i < ngx_last_process; i++) { | 243 for (i = 0; i < ngx_last_process; i++) { |
226 if (ngx_processes[i].pid == pid) { | 244 if (ngx_processes[i].pid == pid) { |
227 ngx_processes[i].status = status; | 245 ngx_processes[i].status = status; |
228 ngx_processes[i].exited = 1; | 246 ngx_processes[i].exited = 1; |
229 process = ngx_processes[i].name; | 247 process = ngx_processes[i].name; |
230 break; | 248 break; |
231 } | 249 } |
232 } | 250 } |
233 | 251 |
234 if (i == ngx_last_process) { | |
235 process = "unknown process"; | |
236 } | |
237 | |
238 if (WTERMSIG(status)) { | 252 if (WTERMSIG(status)) { |
239 ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, 0, | 253 ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, 0, |
240 "%s " PID_T_FMT " exited on signal %d%s", | 254 "%s " PID_T_FMT " exited on signal %d%s", |
241 process, pid, WTERMSIG(status), | 255 process, pid, WTERMSIG(status), |
242 WCOREDUMP(status) ? " (core dumped)" : ""); | 256 WCOREDUMP(status) ? " (core dumped)" : ""); |