From afad21917584e9b452ba33ce3485edde5615b859 Mon Sep 17 00:00:00 2001 From: Ruslan Ermilov Date: Tue, 28 Nov 2017 12:00:24 +0300 Subject: Fixed "changing binary" when reaper is not init. On some systems, it's possible that reaper of orphaned processes is set to something other than "init" process. On such systems, the changing binary procedure did not work. The fix is to check if PPID has changed, instead of assuming it's always 1 for orphaned processes. --- src/os/unix/ngx_process.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/os/unix/ngx_process.c') 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. */ -- cgit v1.2.3