Mercurial > hg > nginx-quic
comparison src/os/unix/ngx_process.c @ 6985:23ecffd5bcfe
Core: signal sender pid logging.
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Thu, 20 Apr 2017 13:58:16 +0300 |
parents | e54c336d95aa |
children | f38647c651a8 |
comparison
equal
deleted
inserted
replaced
6984:201038680680 | 6985:23ecffd5bcfe |
---|---|
13 | 13 |
14 typedef struct { | 14 typedef struct { |
15 int signo; | 15 int signo; |
16 char *signame; | 16 char *signame; |
17 char *name; | 17 char *name; |
18 void (*handler)(int signo); | 18 void (*handler)(int signo, siginfo_t *siginfo, void *ucontext); |
19 } ngx_signal_t; | 19 } ngx_signal_t; |
20 | 20 |
21 | 21 |
22 | 22 |
23 static void ngx_execute_proc(ngx_cycle_t *cycle, void *data); | 23 static void ngx_execute_proc(ngx_cycle_t *cycle, void *data); |
24 static void ngx_signal_handler(int signo); | 24 static void ngx_signal_handler(int signo, siginfo_t *siginfo, void *ucontext); |
25 static void ngx_process_get_status(void); | 25 static void ngx_process_get_status(void); |
26 static void ngx_unlock_mutexes(ngx_pid_t pid); | 26 static void ngx_unlock_mutexes(ngx_pid_t pid); |
27 | 27 |
28 | 28 |
29 int ngx_argc; | 29 int ngx_argc; |
73 | 73 |
74 { SIGIO, "SIGIO", "", ngx_signal_handler }, | 74 { SIGIO, "SIGIO", "", ngx_signal_handler }, |
75 | 75 |
76 { SIGCHLD, "SIGCHLD", "", ngx_signal_handler }, | 76 { SIGCHLD, "SIGCHLD", "", ngx_signal_handler }, |
77 | 77 |
78 { SIGSYS, "SIGSYS, SIG_IGN", "", SIG_IGN }, | 78 { SIGSYS, "SIGSYS, SIG_IGN", "", NULL }, |
79 | 79 |
80 { SIGPIPE, "SIGPIPE, SIG_IGN", "", SIG_IGN }, | 80 { SIGPIPE, "SIGPIPE, SIG_IGN", "", NULL }, |
81 | 81 |
82 { 0, NULL, "", NULL } | 82 { 0, NULL, "", NULL } |
83 }; | 83 }; |
84 | 84 |
85 | 85 |
286 ngx_signal_t *sig; | 286 ngx_signal_t *sig; |
287 struct sigaction sa; | 287 struct sigaction sa; |
288 | 288 |
289 for (sig = signals; sig->signo != 0; sig++) { | 289 for (sig = signals; sig->signo != 0; sig++) { |
290 ngx_memzero(&sa, sizeof(struct sigaction)); | 290 ngx_memzero(&sa, sizeof(struct sigaction)); |
291 sa.sa_handler = sig->handler; | 291 |
292 if (sig->handler) { | |
293 sa.sa_sigaction = sig->handler; | |
294 sa.sa_flags = SA_SIGINFO; | |
295 | |
296 } else { | |
297 sa.sa_handler = SIG_IGN; | |
298 } | |
299 | |
292 sigemptyset(&sa.sa_mask); | 300 sigemptyset(&sa.sa_mask); |
293 if (sigaction(sig->signo, &sa, NULL) == -1) { | 301 if (sigaction(sig->signo, &sa, NULL) == -1) { |
294 #if (NGX_VALGRIND) | 302 #if (NGX_VALGRIND) |
295 ngx_log_error(NGX_LOG_ALERT, log, ngx_errno, | 303 ngx_log_error(NGX_LOG_ALERT, log, ngx_errno, |
296 "sigaction(%s) failed, ignored", sig->signame); | 304 "sigaction(%s) failed, ignored", sig->signame); |
305 return NGX_OK; | 313 return NGX_OK; |
306 } | 314 } |
307 | 315 |
308 | 316 |
309 static void | 317 static void |
310 ngx_signal_handler(int signo) | 318 ngx_signal_handler(int signo, siginfo_t *siginfo, void *ucontext) |
311 { | 319 { |
312 char *action; | 320 char *action; |
313 ngx_int_t ignore; | 321 ngx_int_t ignore; |
314 ngx_err_t err; | 322 ngx_err_t err; |
315 ngx_signal_t *sig; | 323 ngx_signal_t *sig; |
429 } | 437 } |
430 | 438 |
431 break; | 439 break; |
432 } | 440 } |
433 | 441 |
434 ngx_log_error(NGX_LOG_NOTICE, ngx_cycle->log, 0, | 442 if (siginfo && siginfo->si_pid) { |
435 "signal %d (%s) received%s", signo, sig->signame, action); | 443 ngx_log_error(NGX_LOG_NOTICE, ngx_cycle->log, 0, |
444 "signal %d (%s) received from %P%s", | |
445 signo, sig->signame, siginfo->si_pid, action); | |
446 | |
447 } else { | |
448 ngx_log_error(NGX_LOG_NOTICE, ngx_cycle->log, 0, | |
449 "signal %d (%s) received%s", | |
450 signo, sig->signame, action); | |
451 } | |
436 | 452 |
437 if (ignore) { | 453 if (ignore) { |
438 ngx_log_error(NGX_LOG_CRIT, ngx_cycle->log, 0, | 454 ngx_log_error(NGX_LOG_CRIT, ngx_cycle->log, 0, |
439 "the changing binary signal is ignored: " | 455 "the changing binary signal is ignored: " |
440 "you should shutdown or terminate " | 456 "you should shutdown or terminate " |