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

Phil Pennock nginx+phil at
Thu Aug 8 18:50:28 UTC 2013

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.


More information about the nginx mailing list