Forum: NGINX Worker process is not getting killed , when master is killed using -9

B8182c95cf5d0f427920118d6d2e4153?d=identicon&s=25 Vivek Goel (Guest)
on 2013-08-08 08:30
(Received via mailing list)
Hi,
I am facing one problem with nginx.  I am waiting for nginx to stop
withing
30 seconds. If it is not getting stopped, I am firing command to kill
master process using
pkill -9 <master_process_pid>

But, Killing master is not killing the worker process. Due to that
reason.
Port is not getting released.

Is it known problem  or desired behavior ?

regards
Vivek Goel
6596b699dbe76426e360d660922b50b0?d=identicon&s=25 Phil Pennock (Guest)
on 2013-08-08 20:51
(Received via mailing list)
On 2013-08-08 at 06:29 +0000, Vivek Goel wrote:
> I am facing one problem with nginx.  I am waiting for nginx to stop withing
> 30 seconds. If it is not getting stopped, I am firing command to kill
> master process using
> pkill -9 <master_process_pid>
>
> But, Killing master is not killing the worker process. Due to that reason.
> Port is not getting released.
>
> Is it known problem  or desired behavior ?

Fundamental Unix: the process never gets a chance to kill the children
when you use -9.

Instead, you want to use `pkill ... -g <master_process_pid>`.

The -g says to use the "process group"; you can send a signal to all
processes in a group [killpg(2)] and the nginx worker processes are part
of the same process group as the nginx master process, which is the
process group leader (so its pid is the pgid of all the processes you
care about).

Do please try to use -TERM once with the process-group kill, to give the
workers a chance to clean up safely, before you hit all of the processes
at once with the nuclear option.

Regards,
-Phil
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.