Mercurial > hg > nginx
annotate src/os/unix/ngx_process.c @ 8550:234e9d89ff7f quic
HTTP/3: reject HTTP/2 frames.
As per HTTP/3 draft 30, section 7.2.8:
Frame types that were used in HTTP/2 where there is no corresponding
HTTP/3 frame have also been reserved (Section 11.2.1). These frame
types MUST NOT be sent, and their receipt MUST be treated as a
connection error of type H3_FRAME_UNEXPECTED.
author | Roman Arutyunyan <arut@nginx.com> |
---|---|
date | Wed, 16 Sep 2020 12:27:23 +0100 |
parents | 8b84d60ef13d |
children |
rev | line source |
---|---|
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
391
diff
changeset
|
1 |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
391
diff
changeset
|
2 /* |
444
42d11f017717
nginx-0.1.0-2004-09-29-20:00:49 import; remove years from copyright
Igor Sysoev <igor@sysoev.ru>
parents:
441
diff
changeset
|
3 * Copyright (C) Igor Sysoev |
4412 | 4 * Copyright (C) Nginx, Inc. |
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
391
diff
changeset
|
5 */ |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
391
diff
changeset
|
6 |
191
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
7 |
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
8 #include <ngx_config.h> |
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
9 #include <ngx_core.h> |
306
6b91bfbc4123
nginx-0.0.3-2004-04-05-00:32:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
279
diff
changeset
|
10 #include <ngx_event.h> |
391
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
389
diff
changeset
|
11 #include <ngx_channel.h> |
191
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
12 |
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
13 |
539 | 14 typedef struct { |
3681 | 15 int signo; |
16 char *signame; | |
17 char *name; | |
6985
23ecffd5bcfe
Core: signal sender pid logging.
Igor Sysoev <igor@sysoev.ru>
parents:
6932
diff
changeset
|
18 void (*handler)(int signo, siginfo_t *siginfo, void *ucontext); |
539 | 19 } ngx_signal_t; |
20 | |
21 | |
22 | |
279
b79f021a644a
nginx-0.0.2-2004-03-04-19:34:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
272
diff
changeset
|
23 static void ngx_execute_proc(ngx_cycle_t *cycle, void *data); |
6985
23ecffd5bcfe
Core: signal sender pid logging.
Igor Sysoev <igor@sysoev.ru>
parents:
6932
diff
changeset
|
24 static void ngx_signal_handler(int signo, siginfo_t *siginfo, void *ucontext); |
539 | 25 static void ngx_process_get_status(void); |
4311
45272aab5eea
Unlock of shared memory zones on process crash.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4309
diff
changeset
|
26 static void ngx_unlock_mutexes(ngx_pid_t pid); |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
27 |
452 | 28 |
29 int ngx_argc; | |
30 char **ngx_argv; | |
31 char **ngx_os_argv; | |
32 | |
33 ngx_int_t ngx_process_slot; | |
34 ngx_socket_t ngx_channel; | |
35 ngx_int_t ngx_last_process; | |
36 ngx_process_t ngx_processes[NGX_MAX_PROCESSES]; | |
191
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
37 |
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
38 |
539 | 39 ngx_signal_t signals[] = { |
40 { ngx_signal_value(NGX_RECONFIGURE_SIGNAL), | |
41 "SIG" ngx_value(NGX_RECONFIGURE_SIGNAL), | |
2738
ae81441e23f4
implement "-s signal" option for Unix
Igor Sysoev <igor@sysoev.ru>
parents:
2494
diff
changeset
|
42 "reload", |
539 | 43 ngx_signal_handler }, |
44 | |
45 { ngx_signal_value(NGX_REOPEN_SIGNAL), | |
46 "SIG" ngx_value(NGX_REOPEN_SIGNAL), | |
2738
ae81441e23f4
implement "-s signal" option for Unix
Igor Sysoev <igor@sysoev.ru>
parents:
2494
diff
changeset
|
47 "reopen", |
539 | 48 ngx_signal_handler }, |
49 | |
50 { ngx_signal_value(NGX_NOACCEPT_SIGNAL), | |
51 "SIG" ngx_value(NGX_NOACCEPT_SIGNAL), | |
2738
ae81441e23f4
implement "-s signal" option for Unix
Igor Sysoev <igor@sysoev.ru>
parents:
2494
diff
changeset
|
52 "", |
539 | 53 ngx_signal_handler }, |
54 | |
55 { ngx_signal_value(NGX_TERMINATE_SIGNAL), | |
56 "SIG" ngx_value(NGX_TERMINATE_SIGNAL), | |
2738
ae81441e23f4
implement "-s signal" option for Unix
Igor Sysoev <igor@sysoev.ru>
parents:
2494
diff
changeset
|
57 "stop", |
539 | 58 ngx_signal_handler }, |
59 | |
60 { ngx_signal_value(NGX_SHUTDOWN_SIGNAL), | |
61 "SIG" ngx_value(NGX_SHUTDOWN_SIGNAL), | |
2738
ae81441e23f4
implement "-s signal" option for Unix
Igor Sysoev <igor@sysoev.ru>
parents:
2494
diff
changeset
|
62 "quit", |
539 | 63 ngx_signal_handler }, |
64 | |
65 { ngx_signal_value(NGX_CHANGEBIN_SIGNAL), | |
66 "SIG" ngx_value(NGX_CHANGEBIN_SIGNAL), | |
2738
ae81441e23f4
implement "-s signal" option for Unix
Igor Sysoev <igor@sysoev.ru>
parents:
2494
diff
changeset
|
67 "", |
539 | 68 ngx_signal_handler }, |
69 | |
2738
ae81441e23f4
implement "-s signal" option for Unix
Igor Sysoev <igor@sysoev.ru>
parents:
2494
diff
changeset
|
70 { SIGALRM, "SIGALRM", "", ngx_signal_handler }, |
539 | 71 |
2738
ae81441e23f4
implement "-s signal" option for Unix
Igor Sysoev <igor@sysoev.ru>
parents:
2494
diff
changeset
|
72 { SIGINT, "SIGINT", "", ngx_signal_handler }, |
539 | 73 |
2738
ae81441e23f4
implement "-s signal" option for Unix
Igor Sysoev <igor@sysoev.ru>
parents:
2494
diff
changeset
|
74 { SIGIO, "SIGIO", "", ngx_signal_handler }, |
539 | 75 |
2738
ae81441e23f4
implement "-s signal" option for Unix
Igor Sysoev <igor@sysoev.ru>
parents:
2494
diff
changeset
|
76 { SIGCHLD, "SIGCHLD", "", ngx_signal_handler }, |
539 | 77 |
6985
23ecffd5bcfe
Core: signal sender pid logging.
Igor Sysoev <igor@sysoev.ru>
parents:
6932
diff
changeset
|
78 { SIGSYS, "SIGSYS, SIG_IGN", "", NULL }, |
3045 | 79 |
6985
23ecffd5bcfe
Core: signal sender pid logging.
Igor Sysoev <igor@sysoev.ru>
parents:
6932
diff
changeset
|
80 { SIGPIPE, "SIGPIPE, SIG_IGN", "", NULL }, |
539 | 81 |
2738
ae81441e23f4
implement "-s signal" option for Unix
Igor Sysoev <igor@sysoev.ru>
parents:
2494
diff
changeset
|
82 { 0, NULL, "", NULL } |
539 | 83 }; |
84 | |
85 | |
515 | 86 ngx_pid_t |
87 ngx_spawn_process(ngx_cycle_t *cycle, ngx_spawn_proc_pt proc, void *data, | |
88 char *name, ngx_int_t respawn) | |
191
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
89 { |
354
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
90 u_long on; |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
91 ngx_pid_t pid; |
354
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
92 ngx_int_t s; |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
93 |
389
537de4dca8ca
nginx-0.0.7-2004-07-13-21:59:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
366
diff
changeset
|
94 if (respawn >= 0) { |
537de4dca8ca
nginx-0.0.7-2004-07-13-21:59:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
366
diff
changeset
|
95 s = respawn; |
537de4dca8ca
nginx-0.0.7-2004-07-13-21:59:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
366
diff
changeset
|
96 |
537de4dca8ca
nginx-0.0.7-2004-07-13-21:59:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
366
diff
changeset
|
97 } else { |
537de4dca8ca
nginx-0.0.7-2004-07-13-21:59:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
366
diff
changeset
|
98 for (s = 0; s < ngx_last_process; s++) { |
537de4dca8ca
nginx-0.0.7-2004-07-13-21:59:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
366
diff
changeset
|
99 if (ngx_processes[s].pid == -1) { |
537de4dca8ca
nginx-0.0.7-2004-07-13-21:59:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
366
diff
changeset
|
100 break; |
537de4dca8ca
nginx-0.0.7-2004-07-13-21:59:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
366
diff
changeset
|
101 } |
537de4dca8ca
nginx-0.0.7-2004-07-13-21:59:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
366
diff
changeset
|
102 } |
537de4dca8ca
nginx-0.0.7-2004-07-13-21:59:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
366
diff
changeset
|
103 |
537de4dca8ca
nginx-0.0.7-2004-07-13-21:59:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
366
diff
changeset
|
104 if (s == NGX_MAX_PROCESSES) { |
537de4dca8ca
nginx-0.0.7-2004-07-13-21:59:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
366
diff
changeset
|
105 ngx_log_error(NGX_LOG_ALERT, cycle->log, 0, |
537de4dca8ca
nginx-0.0.7-2004-07-13-21:59:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
366
diff
changeset
|
106 "no more than %d processes can be spawned", |
537de4dca8ca
nginx-0.0.7-2004-07-13-21:59:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
366
diff
changeset
|
107 NGX_MAX_PROCESSES); |
543 | 108 return NGX_INVALID_PID; |
389
537de4dca8ca
nginx-0.0.7-2004-07-13-21:59:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
366
diff
changeset
|
109 } |
537de4dca8ca
nginx-0.0.7-2004-07-13-21:59:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
366
diff
changeset
|
110 } |
354
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
111 |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
112 |
365
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
360
diff
changeset
|
113 if (respawn != NGX_PROCESS_DETACHED) { |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
360
diff
changeset
|
114 |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
360
diff
changeset
|
115 /* Solaris 9 still has no AF_LOCAL */ |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
360
diff
changeset
|
116 |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
360
diff
changeset
|
117 if (socketpair(AF_UNIX, SOCK_STREAM, 0, ngx_processes[s].channel) == -1) |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
360
diff
changeset
|
118 { |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
360
diff
changeset
|
119 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
360
diff
changeset
|
120 "socketpair() failed while spawning \"%s\"", name); |
543 | 121 return NGX_INVALID_PID; |
365
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
360
diff
changeset
|
122 } |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
360
diff
changeset
|
123 |
391
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
389
diff
changeset
|
124 ngx_log_debug2(NGX_LOG_DEBUG_CORE, cycle->log, 0, |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
389
diff
changeset
|
125 "channel %d:%d", |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
389
diff
changeset
|
126 ngx_processes[s].channel[0], |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
389
diff
changeset
|
127 ngx_processes[s].channel[1]); |
b670db10cbbd
nginx-0.0.7-2004-07-14-20:01:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
389
diff
changeset
|
128 |
365
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
360
diff
changeset
|
129 if (ngx_nonblocking(ngx_processes[s].channel[0]) == -1) { |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
360
diff
changeset
|
130 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
360
diff
changeset
|
131 ngx_nonblocking_n " failed while spawning \"%s\"", |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
360
diff
changeset
|
132 name); |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
360
diff
changeset
|
133 ngx_close_channel(ngx_processes[s].channel, cycle->log); |
543 | 134 return NGX_INVALID_PID; |
365
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
360
diff
changeset
|
135 } |
354
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
136 |
365
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
360
diff
changeset
|
137 if (ngx_nonblocking(ngx_processes[s].channel[1]) == -1) { |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
360
diff
changeset
|
138 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
360
diff
changeset
|
139 ngx_nonblocking_n " failed while spawning \"%s\"", |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
360
diff
changeset
|
140 name); |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
360
diff
changeset
|
141 ngx_close_channel(ngx_processes[s].channel, cycle->log); |
543 | 142 return NGX_INVALID_PID; |
365
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
360
diff
changeset
|
143 } |
354
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
144 |
365
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
360
diff
changeset
|
145 on = 1; |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
360
diff
changeset
|
146 if (ioctl(ngx_processes[s].channel[0], FIOASYNC, &on) == -1) { |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
360
diff
changeset
|
147 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
360
diff
changeset
|
148 "ioctl(FIOASYNC) failed while spawning \"%s\"", name); |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
360
diff
changeset
|
149 ngx_close_channel(ngx_processes[s].channel, cycle->log); |
543 | 150 return NGX_INVALID_PID; |
365
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
360
diff
changeset
|
151 } |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
360
diff
changeset
|
152 |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
360
diff
changeset
|
153 if (fcntl(ngx_processes[s].channel[0], F_SETOWN, ngx_pid) == -1) { |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
360
diff
changeset
|
154 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
360
diff
changeset
|
155 "fcntl(F_SETOWN) failed while spawning \"%s\"", name); |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
360
diff
changeset
|
156 ngx_close_channel(ngx_processes[s].channel, cycle->log); |
543 | 157 return NGX_INVALID_PID; |
365
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
360
diff
changeset
|
158 } |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
360
diff
changeset
|
159 |
366
e411b1482ee3
nginx-0.0.7-2004-06-23-19:18:17 import
Igor Sysoev <igor@sysoev.ru>
parents:
365
diff
changeset
|
160 if (fcntl(ngx_processes[s].channel[0], F_SETFD, FD_CLOEXEC) == -1) { |
e411b1482ee3
nginx-0.0.7-2004-06-23-19:18:17 import
Igor Sysoev <igor@sysoev.ru>
parents:
365
diff
changeset
|
161 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, |
e411b1482ee3
nginx-0.0.7-2004-06-23-19:18:17 import
Igor Sysoev <igor@sysoev.ru>
parents:
365
diff
changeset
|
162 "fcntl(FD_CLOEXEC) failed while spawning \"%s\"", |
e411b1482ee3
nginx-0.0.7-2004-06-23-19:18:17 import
Igor Sysoev <igor@sysoev.ru>
parents:
365
diff
changeset
|
163 name); |
e411b1482ee3
nginx-0.0.7-2004-06-23-19:18:17 import
Igor Sysoev <igor@sysoev.ru>
parents:
365
diff
changeset
|
164 ngx_close_channel(ngx_processes[s].channel, cycle->log); |
543 | 165 return NGX_INVALID_PID; |
366
e411b1482ee3
nginx-0.0.7-2004-06-23-19:18:17 import
Igor Sysoev <igor@sysoev.ru>
parents:
365
diff
changeset
|
166 } |
e411b1482ee3
nginx-0.0.7-2004-06-23-19:18:17 import
Igor Sysoev <igor@sysoev.ru>
parents:
365
diff
changeset
|
167 |
e411b1482ee3
nginx-0.0.7-2004-06-23-19:18:17 import
Igor Sysoev <igor@sysoev.ru>
parents:
365
diff
changeset
|
168 if (fcntl(ngx_processes[s].channel[1], F_SETFD, FD_CLOEXEC) == -1) { |
e411b1482ee3
nginx-0.0.7-2004-06-23-19:18:17 import
Igor Sysoev <igor@sysoev.ru>
parents:
365
diff
changeset
|
169 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, |
e411b1482ee3
nginx-0.0.7-2004-06-23-19:18:17 import
Igor Sysoev <igor@sysoev.ru>
parents:
365
diff
changeset
|
170 "fcntl(FD_CLOEXEC) failed while spawning \"%s\"", |
e411b1482ee3
nginx-0.0.7-2004-06-23-19:18:17 import
Igor Sysoev <igor@sysoev.ru>
parents:
365
diff
changeset
|
171 name); |
e411b1482ee3
nginx-0.0.7-2004-06-23-19:18:17 import
Igor Sysoev <igor@sysoev.ru>
parents:
365
diff
changeset
|
172 ngx_close_channel(ngx_processes[s].channel, cycle->log); |
543 | 173 return NGX_INVALID_PID; |
366
e411b1482ee3
nginx-0.0.7-2004-06-23-19:18:17 import
Igor Sysoev <igor@sysoev.ru>
parents:
365
diff
changeset
|
174 } |
e411b1482ee3
nginx-0.0.7-2004-06-23-19:18:17 import
Igor Sysoev <igor@sysoev.ru>
parents:
365
diff
changeset
|
175 |
365
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
360
diff
changeset
|
176 ngx_channel = ngx_processes[s].channel[1]; |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
360
diff
changeset
|
177 |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
360
diff
changeset
|
178 } else { |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
360
diff
changeset
|
179 ngx_processes[s].channel[0] = -1; |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
360
diff
changeset
|
180 ngx_processes[s].channel[1] = -1; |
360
239e37d44a34
nginx-0.0.7-2004-06-18-20:22:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
355
diff
changeset
|
181 } |
239e37d44a34
nginx-0.0.7-2004-06-18-20:22:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
355
diff
changeset
|
182 |
239e37d44a34
nginx-0.0.7-2004-06-18-20:22:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
355
diff
changeset
|
183 ngx_process_slot = s; |
354
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
184 |
191
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
185 |
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
186 pid = fork(); |
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
187 |
354
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
188 switch (pid) { |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
189 |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
190 case -1: |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
191 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
192 "fork() failed while spawning \"%s\"", name); |
365
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
360
diff
changeset
|
193 ngx_close_channel(ngx_processes[s].channel, cycle->log); |
543 | 194 return NGX_INVALID_PID; |
191
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
195 |
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
196 case 0: |
7162
8b84d60ef13d
Fixed "changing binary" when reaper is not init.
Ruslan Ermilov <ru@nginx.com>
parents:
6994
diff
changeset
|
197 ngx_parent = ngx_pid; |
249
2a0540287298
nginx-0.0.2-2004-02-03-19:43:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
248
diff
changeset
|
198 ngx_pid = ngx_getpid(); |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
199 proc(cycle, data); |
191
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
200 break; |
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
201 |
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
202 default: |
195
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
191
diff
changeset
|
203 break; |
191
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
204 } |
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
205 |
477 | 206 ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "start %s %P", name, pid); |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
207 |
354
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
208 ngx_processes[s].pid = pid; |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
209 ngx_processes[s].exited = 0; |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
210 |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
211 if (respawn >= 0) { |
225
2e9a8a14a0cf
nginx-0.0.1-2004-01-13-19:43:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
224
diff
changeset
|
212 return pid; |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
213 } |
191
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
214 |
354
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
215 ngx_processes[s].proc = proc; |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
216 ngx_processes[s].data = data; |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
217 ngx_processes[s].name = name; |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
218 ngx_processes[s].exiting = 0; |
318
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
219 |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
220 switch (respawn) { |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
221 |
3016
d82993af1da0
introduce NGX_PROCESS_JUST_SPAWN and change field name accordingly
Igor Sysoev <igor@sysoev.ru>
parents:
2738
diff
changeset
|
222 case NGX_PROCESS_NORESPAWN: |
d82993af1da0
introduce NGX_PROCESS_JUST_SPAWN and change field name accordingly
Igor Sysoev <igor@sysoev.ru>
parents:
2738
diff
changeset
|
223 ngx_processes[s].respawn = 0; |
d82993af1da0
introduce NGX_PROCESS_JUST_SPAWN and change field name accordingly
Igor Sysoev <igor@sysoev.ru>
parents:
2738
diff
changeset
|
224 ngx_processes[s].just_spawn = 0; |
d82993af1da0
introduce NGX_PROCESS_JUST_SPAWN and change field name accordingly
Igor Sysoev <igor@sysoev.ru>
parents:
2738
diff
changeset
|
225 ngx_processes[s].detached = 0; |
d82993af1da0
introduce NGX_PROCESS_JUST_SPAWN and change field name accordingly
Igor Sysoev <igor@sysoev.ru>
parents:
2738
diff
changeset
|
226 break; |
d82993af1da0
introduce NGX_PROCESS_JUST_SPAWN and change field name accordingly
Igor Sysoev <igor@sysoev.ru>
parents:
2738
diff
changeset
|
227 |
d82993af1da0
introduce NGX_PROCESS_JUST_SPAWN and change field name accordingly
Igor Sysoev <igor@sysoev.ru>
parents:
2738
diff
changeset
|
228 case NGX_PROCESS_JUST_SPAWN: |
d82993af1da0
introduce NGX_PROCESS_JUST_SPAWN and change field name accordingly
Igor Sysoev <igor@sysoev.ru>
parents:
2738
diff
changeset
|
229 ngx_processes[s].respawn = 0; |
d82993af1da0
introduce NGX_PROCESS_JUST_SPAWN and change field name accordingly
Igor Sysoev <igor@sysoev.ru>
parents:
2738
diff
changeset
|
230 ngx_processes[s].just_spawn = 1; |
d82993af1da0
introduce NGX_PROCESS_JUST_SPAWN and change field name accordingly
Igor Sysoev <igor@sysoev.ru>
parents:
2738
diff
changeset
|
231 ngx_processes[s].detached = 0; |
d82993af1da0
introduce NGX_PROCESS_JUST_SPAWN and change field name accordingly
Igor Sysoev <igor@sysoev.ru>
parents:
2738
diff
changeset
|
232 break; |
d82993af1da0
introduce NGX_PROCESS_JUST_SPAWN and change field name accordingly
Igor Sysoev <igor@sysoev.ru>
parents:
2738
diff
changeset
|
233 |
318
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
234 case NGX_PROCESS_RESPAWN: |
354
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
235 ngx_processes[s].respawn = 1; |
3016
d82993af1da0
introduce NGX_PROCESS_JUST_SPAWN and change field name accordingly
Igor Sysoev <igor@sysoev.ru>
parents:
2738
diff
changeset
|
236 ngx_processes[s].just_spawn = 0; |
354
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
237 ngx_processes[s].detached = 0; |
318
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
238 break; |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
239 |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
240 case NGX_PROCESS_JUST_RESPAWN: |
354
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
241 ngx_processes[s].respawn = 1; |
3016
d82993af1da0
introduce NGX_PROCESS_JUST_SPAWN and change field name accordingly
Igor Sysoev <igor@sysoev.ru>
parents:
2738
diff
changeset
|
242 ngx_processes[s].just_spawn = 1; |
354
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
243 ngx_processes[s].detached = 0; |
318
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
244 break; |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
245 |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
246 case NGX_PROCESS_DETACHED: |
354
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
247 ngx_processes[s].respawn = 0; |
3016
d82993af1da0
introduce NGX_PROCESS_JUST_SPAWN and change field name accordingly
Igor Sysoev <igor@sysoev.ru>
parents:
2738
diff
changeset
|
248 ngx_processes[s].just_spawn = 0; |
354
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
249 ngx_processes[s].detached = 1; |
318
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
250 break; |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
251 } |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
306
diff
changeset
|
252 |
389
537de4dca8ca
nginx-0.0.7-2004-07-13-21:59:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
366
diff
changeset
|
253 if (s == ngx_last_process) { |
537de4dca8ca
nginx-0.0.7-2004-07-13-21:59:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
366
diff
changeset
|
254 ngx_last_process++; |
537de4dca8ca
nginx-0.0.7-2004-07-13-21:59:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
366
diff
changeset
|
255 } |
191
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
256 |
225
2e9a8a14a0cf
nginx-0.0.1-2004-01-13-19:43:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
224
diff
changeset
|
257 return pid; |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
258 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
259 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
260 |
515 | 261 ngx_pid_t |
262 ngx_execute(ngx_cycle_t *cycle, ngx_exec_ctx_t *ctx) | |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
263 { |
279
b79f021a644a
nginx-0.0.2-2004-03-04-19:34:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
272
diff
changeset
|
264 return ngx_spawn_process(cycle, ngx_execute_proc, ctx, ctx->name, |
226
b0c1e21e68db
nginx-0.0.1-2004-01-14-00:33:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
225
diff
changeset
|
265 NGX_PROCESS_DETACHED); |
191
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
266 } |
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
267 |
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
268 |
515 | 269 static void |
270 ngx_execute_proc(ngx_cycle_t *cycle, void *data) | |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
271 { |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
272 ngx_exec_ctx_t *ctx = data; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
273 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
274 if (execve(ctx->path, ctx->argv, ctx->envp) == -1) { |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
275 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
276 "execve() failed while executing %s \"%s\"", |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
277 ctx->name, ctx->path); |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
278 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
279 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
280 exit(1); |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
281 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
282 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
283 |
539 | 284 ngx_int_t |
285 ngx_init_signals(ngx_log_t *log) | |
286 { | |
287 ngx_signal_t *sig; | |
288 struct sigaction sa; | |
289 | |
290 for (sig = signals; sig->signo != 0; sig++) { | |
291 ngx_memzero(&sa, sizeof(struct sigaction)); | |
6985
23ecffd5bcfe
Core: signal sender pid logging.
Igor Sysoev <igor@sysoev.ru>
parents:
6932
diff
changeset
|
292 |
23ecffd5bcfe
Core: signal sender pid logging.
Igor Sysoev <igor@sysoev.ru>
parents:
6932
diff
changeset
|
293 if (sig->handler) { |
23ecffd5bcfe
Core: signal sender pid logging.
Igor Sysoev <igor@sysoev.ru>
parents:
6932
diff
changeset
|
294 sa.sa_sigaction = sig->handler; |
23ecffd5bcfe
Core: signal sender pid logging.
Igor Sysoev <igor@sysoev.ru>
parents:
6932
diff
changeset
|
295 sa.sa_flags = SA_SIGINFO; |
23ecffd5bcfe
Core: signal sender pid logging.
Igor Sysoev <igor@sysoev.ru>
parents:
6932
diff
changeset
|
296 |
23ecffd5bcfe
Core: signal sender pid logging.
Igor Sysoev <igor@sysoev.ru>
parents:
6932
diff
changeset
|
297 } else { |
23ecffd5bcfe
Core: signal sender pid logging.
Igor Sysoev <igor@sysoev.ru>
parents:
6932
diff
changeset
|
298 sa.sa_handler = SIG_IGN; |
23ecffd5bcfe
Core: signal sender pid logging.
Igor Sysoev <igor@sysoev.ru>
parents:
6932
diff
changeset
|
299 } |
23ecffd5bcfe
Core: signal sender pid logging.
Igor Sysoev <igor@sysoev.ru>
parents:
6932
diff
changeset
|
300 |
539 | 301 sigemptyset(&sa.sa_mask); |
302 if (sigaction(sig->signo, &sa, NULL) == -1) { | |
5244
593d344999f5
Valgrind: sigaction() failure now ignored.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4889
diff
changeset
|
303 #if (NGX_VALGRIND) |
593d344999f5
Valgrind: sigaction() failure now ignored.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4889
diff
changeset
|
304 ngx_log_error(NGX_LOG_ALERT, log, ngx_errno, |
593d344999f5
Valgrind: sigaction() failure now ignored.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4889
diff
changeset
|
305 "sigaction(%s) failed, ignored", sig->signame); |
593d344999f5
Valgrind: sigaction() failure now ignored.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4889
diff
changeset
|
306 #else |
539 | 307 ngx_log_error(NGX_LOG_EMERG, log, ngx_errno, |
308 "sigaction(%s) failed", sig->signame); | |
309 return NGX_ERROR; | |
5244
593d344999f5
Valgrind: sigaction() failure now ignored.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4889
diff
changeset
|
310 #endif |
539 | 311 } |
312 } | |
313 | |
314 return NGX_OK; | |
315 } | |
316 | |
317 | |
6932
e54c336d95aa
Added missing "static" specifier found by gcc -Wtraditional.
Ruslan Ermilov <ru@nginx.com>
parents:
6483
diff
changeset
|
318 static void |
6985
23ecffd5bcfe
Core: signal sender pid logging.
Igor Sysoev <igor@sysoev.ru>
parents:
6932
diff
changeset
|
319 ngx_signal_handler(int signo, siginfo_t *siginfo, void *ucontext) |
539 | 320 { |
321 char *action; | |
322 ngx_int_t ignore; | |
323 ngx_err_t err; | |
324 ngx_signal_t *sig; | |
325 | |
326 ignore = 0; | |
327 | |
328 err = ngx_errno; | |
329 | |
330 for (sig = signals; sig->signo != 0; sig++) { | |
331 if (sig->signo == signo) { | |
332 break; | |
333 } | |
334 } | |
335 | |
3475
ab353d7dc182
*) introduce ngx_time_sigsafe_update() to update the error log time only
Igor Sysoev <igor@sysoev.ru>
parents:
3474
diff
changeset
|
336 ngx_time_sigsafe_update(); |
539 | 337 |
338 action = ""; | |
339 | |
340 switch (ngx_process) { | |
341 | |
342 case NGX_PROCESS_MASTER: | |
343 case NGX_PROCESS_SINGLE: | |
344 switch (signo) { | |
345 | |
346 case ngx_signal_value(NGX_SHUTDOWN_SIGNAL): | |
347 ngx_quit = 1; | |
348 action = ", shutting down"; | |
349 break; | |
350 | |
351 case ngx_signal_value(NGX_TERMINATE_SIGNAL): | |
352 case SIGINT: | |
353 ngx_terminate = 1; | |
354 action = ", exiting"; | |
355 break; | |
356 | |
357 case ngx_signal_value(NGX_NOACCEPT_SIGNAL): | |
4019
5364d2e711cc
SIGWINCH/NOACCEPT signal is disabled now in non-daemon mode.
Igor Sysoev <igor@sysoev.ru>
parents:
3787
diff
changeset
|
358 if (ngx_daemonized) { |
5364d2e711cc
SIGWINCH/NOACCEPT signal is disabled now in non-daemon mode.
Igor Sysoev <igor@sysoev.ru>
parents:
3787
diff
changeset
|
359 ngx_noaccept = 1; |
5364d2e711cc
SIGWINCH/NOACCEPT signal is disabled now in non-daemon mode.
Igor Sysoev <igor@sysoev.ru>
parents:
3787
diff
changeset
|
360 action = ", stop accepting connections"; |
5364d2e711cc
SIGWINCH/NOACCEPT signal is disabled now in non-daemon mode.
Igor Sysoev <igor@sysoev.ru>
parents:
3787
diff
changeset
|
361 } |
539 | 362 break; |
363 | |
364 case ngx_signal_value(NGX_RECONFIGURE_SIGNAL): | |
365 ngx_reconfigure = 1; | |
366 action = ", reconfiguring"; | |
367 break; | |
368 | |
369 case ngx_signal_value(NGX_REOPEN_SIGNAL): | |
370 ngx_reopen = 1; | |
371 action = ", reopening logs"; | |
372 break; | |
373 | |
374 case ngx_signal_value(NGX_CHANGEBIN_SIGNAL): | |
7162
8b84d60ef13d
Fixed "changing binary" when reaper is not init.
Ruslan Ermilov <ru@nginx.com>
parents:
6994
diff
changeset
|
375 if (ngx_getppid() == ngx_parent || ngx_new_binary > 0) { |
539 | 376 |
377 /* | |
378 * Ignore the signal in the new binary if its parent is | |
7162
8b84d60ef13d
Fixed "changing binary" when reaper is not init.
Ruslan Ermilov <ru@nginx.com>
parents:
6994
diff
changeset
|
379 * not changed, i.e. the old binary's process is still |
8b84d60ef13d
Fixed "changing binary" when reaper is not init.
Ruslan Ermilov <ru@nginx.com>
parents:
6994
diff
changeset
|
380 * running. Or ignore the signal in the old binary's |
539 | 381 * process if the new binary's process is already running. |
382 */ | |
383 | |
384 action = ", ignoring"; | |
385 ignore = 1; | |
386 break; | |
387 } | |
388 | |
389 ngx_change_binary = 1; | |
390 action = ", changing binary"; | |
391 break; | |
392 | |
393 case SIGALRM: | |
3048
846d0e2fa483
twice termination delay only after SIGALRM, otherwise many separate SIGCHLD
Igor Sysoev <igor@sysoev.ru>
parents:
3045
diff
changeset
|
394 ngx_sigalrm = 1; |
539 | 395 break; |
396 | |
397 case SIGIO: | |
398 ngx_sigio = 1; | |
399 break; | |
400 | |
401 case SIGCHLD: | |
402 ngx_reap = 1; | |
403 break; | |
404 } | |
405 | |
406 break; | |
407 | |
408 case NGX_PROCESS_WORKER: | |
3358
f94e8ff65aa2
add NGX_PROCESS_HELPER process status
Igor Sysoev <igor@sysoev.ru>
parents:
3048
diff
changeset
|
409 case NGX_PROCESS_HELPER: |
539 | 410 switch (signo) { |
411 | |
412 case ngx_signal_value(NGX_NOACCEPT_SIGNAL): | |
4019
5364d2e711cc
SIGWINCH/NOACCEPT signal is disabled now in non-daemon mode.
Igor Sysoev <igor@sysoev.ru>
parents:
3787
diff
changeset
|
413 if (!ngx_daemonized) { |
5364d2e711cc
SIGWINCH/NOACCEPT signal is disabled now in non-daemon mode.
Igor Sysoev <igor@sysoev.ru>
parents:
3787
diff
changeset
|
414 break; |
5364d2e711cc
SIGWINCH/NOACCEPT signal is disabled now in non-daemon mode.
Igor Sysoev <igor@sysoev.ru>
parents:
3787
diff
changeset
|
415 } |
539 | 416 ngx_debug_quit = 1; |
6994
f38647c651a8
Added missing "fall through" comments (ticket #1259).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6985
diff
changeset
|
417 /* fall through */ |
539 | 418 case ngx_signal_value(NGX_SHUTDOWN_SIGNAL): |
419 ngx_quit = 1; | |
420 action = ", shutting down"; | |
421 break; | |
422 | |
423 case ngx_signal_value(NGX_TERMINATE_SIGNAL): | |
424 case SIGINT: | |
425 ngx_terminate = 1; | |
426 action = ", exiting"; | |
427 break; | |
428 | |
429 case ngx_signal_value(NGX_REOPEN_SIGNAL): | |
430 ngx_reopen = 1; | |
431 action = ", reopening logs"; | |
432 break; | |
433 | |
434 case ngx_signal_value(NGX_RECONFIGURE_SIGNAL): | |
435 case ngx_signal_value(NGX_CHANGEBIN_SIGNAL): | |
436 case SIGIO: | |
437 action = ", ignoring"; | |
438 break; | |
439 } | |
440 | |
441 break; | |
442 } | |
443 | |
6985
23ecffd5bcfe
Core: signal sender pid logging.
Igor Sysoev <igor@sysoev.ru>
parents:
6932
diff
changeset
|
444 if (siginfo && siginfo->si_pid) { |
23ecffd5bcfe
Core: signal sender pid logging.
Igor Sysoev <igor@sysoev.ru>
parents:
6932
diff
changeset
|
445 ngx_log_error(NGX_LOG_NOTICE, ngx_cycle->log, 0, |
23ecffd5bcfe
Core: signal sender pid logging.
Igor Sysoev <igor@sysoev.ru>
parents:
6932
diff
changeset
|
446 "signal %d (%s) received from %P%s", |
23ecffd5bcfe
Core: signal sender pid logging.
Igor Sysoev <igor@sysoev.ru>
parents:
6932
diff
changeset
|
447 signo, sig->signame, siginfo->si_pid, action); |
23ecffd5bcfe
Core: signal sender pid logging.
Igor Sysoev <igor@sysoev.ru>
parents:
6932
diff
changeset
|
448 |
23ecffd5bcfe
Core: signal sender pid logging.
Igor Sysoev <igor@sysoev.ru>
parents:
6932
diff
changeset
|
449 } else { |
23ecffd5bcfe
Core: signal sender pid logging.
Igor Sysoev <igor@sysoev.ru>
parents:
6932
diff
changeset
|
450 ngx_log_error(NGX_LOG_NOTICE, ngx_cycle->log, 0, |
23ecffd5bcfe
Core: signal sender pid logging.
Igor Sysoev <igor@sysoev.ru>
parents:
6932
diff
changeset
|
451 "signal %d (%s) received%s", |
23ecffd5bcfe
Core: signal sender pid logging.
Igor Sysoev <igor@sysoev.ru>
parents:
6932
diff
changeset
|
452 signo, sig->signame, action); |
23ecffd5bcfe
Core: signal sender pid logging.
Igor Sysoev <igor@sysoev.ru>
parents:
6932
diff
changeset
|
453 } |
539 | 454 |
455 if (ignore) { | |
456 ngx_log_error(NGX_LOG_CRIT, ngx_cycle->log, 0, | |
457 "the changing binary signal is ignored: " | |
458 "you should shutdown or terminate " | |
459 "before either old or new binary's process"); | |
460 } | |
461 | |
462 if (signo == SIGCHLD) { | |
463 ngx_process_get_status(); | |
464 } | |
465 | |
466 ngx_set_errno(err); | |
467 } | |
468 | |
469 | |
470 static void | |
515 | 471 ngx_process_get_status(void) |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
472 { |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
473 int status; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
474 char *process; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
475 ngx_pid_t pid; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
476 ngx_err_t err; |
354
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
477 ngx_int_t i; |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
478 ngx_uint_t one; |
477 | 479 |
191
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
480 one = 0; |
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
481 |
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
482 for ( ;; ) { |
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
483 pid = waitpid(-1, &status, WNOHANG); |
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
484 |
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
485 if (pid == 0) { |
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
486 return; |
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
487 } |
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
488 |
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
489 if (pid == -1) { |
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
490 err = ngx_errno; |
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
491 |
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
492 if (err == NGX_EINTR) { |
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
493 continue; |
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
494 } |
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
495 |
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
496 if (err == NGX_ECHILD && one) { |
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
497 return; |
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
498 } |
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
499 |
452 | 500 /* |
501 * Solaris always calls the signal handler for each exited process | |
943
cbe0292e53b3
lower the log level of the waitpid() ENOCHILD error on FreeBSD
Igor Sysoev <igor@sysoev.ru>
parents:
698
diff
changeset
|
502 * despite waitpid() may be already called for this process. |
cbe0292e53b3
lower the log level of the waitpid() ENOCHILD error on FreeBSD
Igor Sysoev <igor@sysoev.ru>
parents:
698
diff
changeset
|
503 * |
cbe0292e53b3
lower the log level of the waitpid() ENOCHILD error on FreeBSD
Igor Sysoev <igor@sysoev.ru>
parents:
698
diff
changeset
|
504 * When several processes exit at the same time FreeBSD may |
cbe0292e53b3
lower the log level of the waitpid() ENOCHILD error on FreeBSD
Igor Sysoev <igor@sysoev.ru>
parents:
698
diff
changeset
|
505 * erroneously call the signal handler for exited process |
1963 | 506 * despite waitpid() may be already called for this process. |
452 | 507 */ |
508 | |
509 if (err == NGX_ECHILD) { | |
3787
e294f37401c0
use copied strerror() messages and autoconfigured sys_nerr value
Igor Sysoev <igor@sysoev.ru>
parents:
3681
diff
changeset
|
510 ngx_log_error(NGX_LOG_INFO, ngx_cycle->log, err, |
e294f37401c0
use copied strerror() messages and autoconfigured sys_nerr value
Igor Sysoev <igor@sysoev.ru>
parents:
3681
diff
changeset
|
511 "waitpid() failed"); |
563 | 512 return; |
452 | 513 } |
514 | |
3787
e294f37401c0
use copied strerror() messages and autoconfigured sys_nerr value
Igor Sysoev <igor@sysoev.ru>
parents:
3681
diff
changeset
|
515 ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, err, |
e294f37401c0
use copied strerror() messages and autoconfigured sys_nerr value
Igor Sysoev <igor@sysoev.ru>
parents:
3681
diff
changeset
|
516 "waitpid() failed"); |
191
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
517 return; |
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
518 } |
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
519 |
306
6b91bfbc4123
nginx-0.0.3-2004-04-05-00:32:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
279
diff
changeset
|
520 |
191
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
521 one = 1; |
389
537de4dca8ca
nginx-0.0.7-2004-07-13-21:59:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
366
diff
changeset
|
522 process = "unknown process"; |
191
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
523 |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
524 for (i = 0; i < ngx_last_process; i++) { |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
525 if (ngx_processes[i].pid == pid) { |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
526 ngx_processes[i].status = status; |
222
99df0edb63ed
nginx-0.0.1-2004-01-09-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
221
diff
changeset
|
527 ngx_processes[i].exited = 1; |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
528 process = ngx_processes[i].name; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
529 break; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
530 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
531 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
532 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
533 if (WTERMSIG(status)) { |
2494 | 534 #ifdef WCOREDUMP |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
535 ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, 0, |
461 | 536 "%s %P exited on signal %d%s", |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
537 process, pid, WTERMSIG(status), |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
538 WCOREDUMP(status) ? " (core dumped)" : ""); |
2494 | 539 #else |
540 ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, 0, | |
541 "%s %P exited on signal %d", | |
542 process, pid, WTERMSIG(status)); | |
543 #endif | |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
544 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
545 } else { |
477 | 546 ngx_log_error(NGX_LOG_NOTICE, ngx_cycle->log, 0, |
461 | 547 "%s %P exited with code %d", |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
548 process, pid, WEXITSTATUS(status)); |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
549 } |
234
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
227
diff
changeset
|
550 |
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
227
diff
changeset
|
551 if (WEXITSTATUS(status) == 2 && ngx_processes[i].respawn) { |
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
227
diff
changeset
|
552 ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, 0, |
1963 | 553 "%s %P exited with fatal code %d " |
4133
59b99f217c6d
Replaced "can not" with "cannot" and "could not" in a bunch of places.
Ruslan Ermilov <ru@nginx.com>
parents:
4019
diff
changeset
|
554 "and cannot be respawned", |
1963 | 555 process, pid, WEXITSTATUS(status)); |
234
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
227
diff
changeset
|
556 ngx_processes[i].respawn = 0; |
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
227
diff
changeset
|
557 } |
4311
45272aab5eea
Unlock of shared memory zones on process crash.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4309
diff
changeset
|
558 |
45272aab5eea
Unlock of shared memory zones on process crash.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4309
diff
changeset
|
559 ngx_unlock_mutexes(pid); |
45272aab5eea
Unlock of shared memory zones on process crash.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4309
diff
changeset
|
560 } |
45272aab5eea
Unlock of shared memory zones on process crash.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4309
diff
changeset
|
561 } |
45272aab5eea
Unlock of shared memory zones on process crash.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4309
diff
changeset
|
562 |
45272aab5eea
Unlock of shared memory zones on process crash.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4309
diff
changeset
|
563 |
45272aab5eea
Unlock of shared memory zones on process crash.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4309
diff
changeset
|
564 static void |
45272aab5eea
Unlock of shared memory zones on process crash.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4309
diff
changeset
|
565 ngx_unlock_mutexes(ngx_pid_t pid) |
4522 | 566 { |
4311
45272aab5eea
Unlock of shared memory zones on process crash.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4309
diff
changeset
|
567 ngx_uint_t i; |
45272aab5eea
Unlock of shared memory zones on process crash.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4309
diff
changeset
|
568 ngx_shm_zone_t *shm_zone; |
45272aab5eea
Unlock of shared memory zones on process crash.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4309
diff
changeset
|
569 ngx_list_part_t *part; |
45272aab5eea
Unlock of shared memory zones on process crash.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4309
diff
changeset
|
570 ngx_slab_pool_t *sp; |
45272aab5eea
Unlock of shared memory zones on process crash.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4309
diff
changeset
|
571 |
45272aab5eea
Unlock of shared memory zones on process crash.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4309
diff
changeset
|
572 /* |
45272aab5eea
Unlock of shared memory zones on process crash.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4309
diff
changeset
|
573 * unlock the accept mutex if the abnormally exited process |
45272aab5eea
Unlock of shared memory zones on process crash.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4309
diff
changeset
|
574 * held it |
45272aab5eea
Unlock of shared memory zones on process crash.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4309
diff
changeset
|
575 */ |
45272aab5eea
Unlock of shared memory zones on process crash.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4309
diff
changeset
|
576 |
45272aab5eea
Unlock of shared memory zones on process crash.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4309
diff
changeset
|
577 if (ngx_accept_mutex_ptr) { |
4315
424a1ac6af43
Added (void) as we intentionally ignore returned values.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4311
diff
changeset
|
578 (void) ngx_shmtx_force_unlock(&ngx_accept_mutex, pid); |
4311
45272aab5eea
Unlock of shared memory zones on process crash.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4309
diff
changeset
|
579 } |
45272aab5eea
Unlock of shared memory zones on process crash.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4309
diff
changeset
|
580 |
45272aab5eea
Unlock of shared memory zones on process crash.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4309
diff
changeset
|
581 /* |
45272aab5eea
Unlock of shared memory zones on process crash.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4309
diff
changeset
|
582 * unlock shared memory mutexes if held by the abnormally exited |
45272aab5eea
Unlock of shared memory zones on process crash.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4309
diff
changeset
|
583 * process |
45272aab5eea
Unlock of shared memory zones on process crash.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4309
diff
changeset
|
584 */ |
45272aab5eea
Unlock of shared memory zones on process crash.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4309
diff
changeset
|
585 |
45272aab5eea
Unlock of shared memory zones on process crash.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4309
diff
changeset
|
586 part = (ngx_list_part_t *) &ngx_cycle->shared_memory.part; |
45272aab5eea
Unlock of shared memory zones on process crash.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4309
diff
changeset
|
587 shm_zone = part->elts; |
45272aab5eea
Unlock of shared memory zones on process crash.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4309
diff
changeset
|
588 |
45272aab5eea
Unlock of shared memory zones on process crash.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4309
diff
changeset
|
589 for (i = 0; /* void */ ; i++) { |
45272aab5eea
Unlock of shared memory zones on process crash.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4309
diff
changeset
|
590 |
45272aab5eea
Unlock of shared memory zones on process crash.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4309
diff
changeset
|
591 if (i >= part->nelts) { |
45272aab5eea
Unlock of shared memory zones on process crash.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4309
diff
changeset
|
592 if (part->next == NULL) { |
45272aab5eea
Unlock of shared memory zones on process crash.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4309
diff
changeset
|
593 break; |
45272aab5eea
Unlock of shared memory zones on process crash.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4309
diff
changeset
|
594 } |
45272aab5eea
Unlock of shared memory zones on process crash.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4309
diff
changeset
|
595 part = part->next; |
45272aab5eea
Unlock of shared memory zones on process crash.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4309
diff
changeset
|
596 shm_zone = part->elts; |
45272aab5eea
Unlock of shared memory zones on process crash.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4309
diff
changeset
|
597 i = 0; |
45272aab5eea
Unlock of shared memory zones on process crash.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4309
diff
changeset
|
598 } |
45272aab5eea
Unlock of shared memory zones on process crash.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4309
diff
changeset
|
599 |
45272aab5eea
Unlock of shared memory zones on process crash.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4309
diff
changeset
|
600 sp = (ngx_slab_pool_t *) shm_zone[i].shm.addr; |
45272aab5eea
Unlock of shared memory zones on process crash.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4309
diff
changeset
|
601 |
45272aab5eea
Unlock of shared memory zones on process crash.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4309
diff
changeset
|
602 if (ngx_shmtx_force_unlock(&sp->mutex, pid)) { |
45272aab5eea
Unlock of shared memory zones on process crash.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4309
diff
changeset
|
603 ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, 0, |
45272aab5eea
Unlock of shared memory zones on process crash.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4309
diff
changeset
|
604 "shared memory zone \"%V\" was locked by %P", |
45272aab5eea
Unlock of shared memory zones on process crash.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4309
diff
changeset
|
605 &shm_zone[i].shm.name, pid); |
45272aab5eea
Unlock of shared memory zones on process crash.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4309
diff
changeset
|
606 } |
191
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
607 } |
71ce40b3c37b
nginx-0.0.1-2003-11-19-19:26:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
608 } |
461 | 609 |
610 | |
515 | 611 void |
612 ngx_debug_point(void) | |
461 | 613 { |
614 ngx_core_conf_t *ccf; | |
615 | |
616 ccf = (ngx_core_conf_t *) ngx_get_conf(ngx_cycle->conf_ctx, | |
617 ngx_core_module); | |
618 | |
619 switch (ccf->debug_points) { | |
620 | |
621 case NGX_DEBUG_POINTS_STOP: | |
622 raise(SIGSTOP); | |
623 break; | |
624 | |
625 case NGX_DEBUG_POINTS_ABORT: | |
563 | 626 ngx_abort(); |
461 | 627 } |
628 } | |
2738
ae81441e23f4
implement "-s signal" option for Unix
Igor Sysoev <igor@sysoev.ru>
parents:
2494
diff
changeset
|
629 |
ae81441e23f4
implement "-s signal" option for Unix
Igor Sysoev <igor@sysoev.ru>
parents:
2494
diff
changeset
|
630 |
ae81441e23f4
implement "-s signal" option for Unix
Igor Sysoev <igor@sysoev.ru>
parents:
2494
diff
changeset
|
631 ngx_int_t |
6483
3a50ccd94333
Fixed ngx_os_signal_process() prototype.
Ruslan Ermilov <ru@nginx.com>
parents:
6482
diff
changeset
|
632 ngx_os_signal_process(ngx_cycle_t *cycle, char *name, ngx_pid_t pid) |
2738
ae81441e23f4
implement "-s signal" option for Unix
Igor Sysoev <igor@sysoev.ru>
parents:
2494
diff
changeset
|
633 { |
ae81441e23f4
implement "-s signal" option for Unix
Igor Sysoev <igor@sysoev.ru>
parents:
2494
diff
changeset
|
634 ngx_signal_t *sig; |
ae81441e23f4
implement "-s signal" option for Unix
Igor Sysoev <igor@sysoev.ru>
parents:
2494
diff
changeset
|
635 |
ae81441e23f4
implement "-s signal" option for Unix
Igor Sysoev <igor@sysoev.ru>
parents:
2494
diff
changeset
|
636 for (sig = signals; sig->signo != 0; sig++) { |
ae81441e23f4
implement "-s signal" option for Unix
Igor Sysoev <igor@sysoev.ru>
parents:
2494
diff
changeset
|
637 if (ngx_strcmp(name, sig->name) == 0) { |
ae81441e23f4
implement "-s signal" option for Unix
Igor Sysoev <igor@sysoev.ru>
parents:
2494
diff
changeset
|
638 if (kill(pid, sig->signo) != -1) { |
ae81441e23f4
implement "-s signal" option for Unix
Igor Sysoev <igor@sysoev.ru>
parents:
2494
diff
changeset
|
639 return 0; |
ae81441e23f4
implement "-s signal" option for Unix
Igor Sysoev <igor@sysoev.ru>
parents:
2494
diff
changeset
|
640 } |
ae81441e23f4
implement "-s signal" option for Unix
Igor Sysoev <igor@sysoev.ru>
parents:
2494
diff
changeset
|
641 |
ae81441e23f4
implement "-s signal" option for Unix
Igor Sysoev <igor@sysoev.ru>
parents:
2494
diff
changeset
|
642 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, |
6483
3a50ccd94333
Fixed ngx_os_signal_process() prototype.
Ruslan Ermilov <ru@nginx.com>
parents:
6482
diff
changeset
|
643 "kill(%P, %d) failed", pid, sig->signo); |
2738
ae81441e23f4
implement "-s signal" option for Unix
Igor Sysoev <igor@sysoev.ru>
parents:
2494
diff
changeset
|
644 } |
ae81441e23f4
implement "-s signal" option for Unix
Igor Sysoev <igor@sysoev.ru>
parents:
2494
diff
changeset
|
645 } |
ae81441e23f4
implement "-s signal" option for Unix
Igor Sysoev <igor@sysoev.ru>
parents:
2494
diff
changeset
|
646 |
ae81441e23f4
implement "-s signal" option for Unix
Igor Sysoev <igor@sysoev.ru>
parents:
2494
diff
changeset
|
647 return 1; |
ae81441e23f4
implement "-s signal" option for Unix
Igor Sysoev <igor@sysoev.ru>
parents:
2494
diff
changeset
|
648 } |