aboutsummaryrefslogtreecommitdiff
path: root/src/os/unix/ngx_posix_init.c
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2004-01-13 21:33:59 +0000
committerIgor Sysoev <igor@sysoev.ru>2004-01-13 21:33:59 +0000
commit80340f0152ad5bb4c0a4fdf88873331e77eae5f5 (patch)
tree463ca3811cc497846674696e38dd87c7df2553d8 /src/os/unix/ngx_posix_init.c
parent49783fc42ec15bfb7c1100be9441e28b0b8f14df (diff)
downloadnginx-80340f0152ad5bb4c0a4fdf88873331e77eae5f5.tar.gz
nginx-80340f0152ad5bb4c0a4fdf88873331e77eae5f5.zip
nginx-0.0.1-2004-01-14-00:33:59 import
Diffstat (limited to 'src/os/unix/ngx_posix_init.c')
-rw-r--r--src/os/unix/ngx_posix_init.c37
1 files changed, 34 insertions, 3 deletions
diff --git a/src/os/unix/ngx_posix_init.c b/src/os/unix/ngx_posix_init.c
index d5f28d0eb..b23dc3122 100644
--- a/src/os/unix/ngx_posix_init.c
+++ b/src/os/unix/ngx_posix_init.c
@@ -42,6 +42,8 @@ ngx_signal_t signals[] = {
"SIG" ngx_value(NGX_CHANGEBIN_SIGNAL),
ngx_signal_handler },
+ { SIGINT, "SIGINT", ngx_signal_handler },
+
{ SIGCHLD, "SIGCHLD", ngx_signal_handler },
{ SIGPIPE, "SIGPIPE, SIG_IGN", SIG_IGN },
@@ -93,10 +95,12 @@ void ngx_signal_handler(int signo)
{
char *action;
struct timeval tv;
+ ngx_int_t ignore;
ngx_err_t err;
ngx_signal_t *sig;
ngx_signal = 1;
+ ignore = 0;
err = ngx_errno;
@@ -138,11 +142,31 @@ void ngx_signal_handler(int signo)
break;
case ngx_signal_value(NGX_REOPEN_SIGNAL):
- ngx_reopen = 1;
- action = ", reopen logs";
- break;
+ if (ngx_noaccept) {
+ action = ", ignoring";
+
+ } else {
+ ngx_reopen = 1;
+ action = ", reopen logs";
+ break;
+ }
case ngx_signal_value(NGX_CHANGEBIN_SIGNAL):
+ if ((ngx_inherited && getppid() > 1)
+ || (!ngx_inherited && ngx_new_binary > 0))
+ {
+ /*
+ * Ignore the signal in the new binary if its parent is
+ * not the init process, i.e. the old binary's process
+ * is still running. Or ingore the signal in the old binary's
+ * process if the new binary's process is already running.
+ */
+
+ action = ", ignoring";
+ ignore = 1;
+ break;
+ }
+
ngx_change_binary = 1;
action = ", changing binary";
break;
@@ -189,6 +213,13 @@ void ngx_signal_handler(int signo)
ngx_log_error(NGX_LOG_INFO, ngx_cycle->log, 0,
"signal %d (%s) received%s", signo, sig->signame, action);
+ if (ignore) {
+ ngx_log_error(NGX_LOG_CRIT, ngx_cycle->log, 0,
+ "the changing binary signal is ignored: "
+ "you should shutdown or terminate "
+ "before either old or new binary's process");
+ }
+
if (signo == SIGCHLD) {
ngx_process_get_status();
}