aboutsummaryrefslogtreecommitdiff
path: root/src/os/unix
diff options
context:
space:
mode:
Diffstat (limited to 'src/os/unix')
-rw-r--r--src/os/unix/ngx_daemon.c1
-rw-r--r--src/os/unix/ngx_process.c7
-rw-r--r--src/os/unix/ngx_process.h2
-rw-r--r--src/os/unix/ngx_process_cycle.c1
4 files changed, 8 insertions, 3 deletions
diff --git a/src/os/unix/ngx_daemon.c b/src/os/unix/ngx_daemon.c
index ab6721108..385c49b6c 100644
--- a/src/os/unix/ngx_daemon.c
+++ b/src/os/unix/ngx_daemon.c
@@ -26,6 +26,7 @@ ngx_daemon(ngx_log_t *log)
exit(0);
}
+ ngx_parent = ngx_pid;
ngx_pid = ngx_getpid();
if (setsid() == -1) {
diff --git a/src/os/unix/ngx_process.c b/src/os/unix/ngx_process.c
index 993c032ae..15680237a 100644
--- a/src/os/unix/ngx_process.c
+++ b/src/os/unix/ngx_process.c
@@ -194,6 +194,7 @@ ngx_spawn_process(ngx_cycle_t *cycle, ngx_spawn_proc_pt proc, void *data,
return NGX_INVALID_PID;
case 0:
+ ngx_parent = ngx_pid;
ngx_pid = ngx_getpid();
proc(cycle, data);
break;
@@ -371,12 +372,12 @@ ngx_signal_handler(int signo, siginfo_t *siginfo, void *ucontext)
break;
case ngx_signal_value(NGX_CHANGEBIN_SIGNAL):
- if (getppid() > 1 || ngx_new_binary > 0) {
+ if (ngx_getppid() == ngx_parent || 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 ignore the signal in the old binary's
+ * not changed, i.e. the old binary's process is still
+ * running. Or ignore the signal in the old binary's
* process if the new binary's process is already running.
*/
diff --git a/src/os/unix/ngx_process.h b/src/os/unix/ngx_process.h
index 7b5e8c0c2..3986639b4 100644
--- a/src/os/unix/ngx_process.h
+++ b/src/os/unix/ngx_process.h
@@ -54,6 +54,7 @@ typedef struct {
#define ngx_getpid getpid
+#define ngx_getppid getppid
#ifndef ngx_log_pid
#define ngx_log_pid ngx_pid
@@ -79,6 +80,7 @@ extern char **ngx_argv;
extern char **ngx_os_argv;
extern ngx_pid_t ngx_pid;
+extern ngx_pid_t ngx_parent;
extern ngx_socket_t ngx_channel;
extern ngx_int_t ngx_process_slot;
extern ngx_int_t ngx_last_process;
diff --git a/src/os/unix/ngx_process_cycle.c b/src/os/unix/ngx_process_cycle.c
index 1710ea812..a20a515c7 100644
--- a/src/os/unix/ngx_process_cycle.c
+++ b/src/os/unix/ngx_process_cycle.c
@@ -31,6 +31,7 @@ static void ngx_cache_loader_process_handler(ngx_event_t *ev);
ngx_uint_t ngx_process;
ngx_uint_t ngx_worker;
ngx_pid_t ngx_pid;
+ngx_pid_t ngx_parent;
sig_atomic_t ngx_reap;
sig_atomic_t ngx_sigio;