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

**URL:** <https://www.ruby-forum.com/t/worker-process-is-not-getting-killed-when-master-is-killed-using-9/236132>\
**Category:** NGINX\
**Created:** [August 8, 2013, 8:30am UTC](https://www.ruby-forum.com/t/worker-process-is-not-getting-killed-when-master-is-killed-using-9/236132 "2013-08-08T08:30:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![alcina](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a587f6/32.png) [@alcina](https://www.ruby-forum.com/u/alcina)\
**Post date:** [August 8, 2013, 8:30am UTC](https://www.ruby-forum.com/t/worker-process-is-not-getting-killed-when-master-is-killed-using-9/236132/1 "2013-08-08T08:30:10Z")

</div>

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 G.

---

<div class="post-metadata">

**Author:** ![vivek112020](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/8c91f0/32.png) [@vivek112020](https://www.ruby-forum.com/u/vivek112020)\
**Post date:** [August 8, 2013, 8:51pm UTC](https://www.ruby-forum.com/t/worker-process-is-not-getting-killed-when-master-is-killed-using-9/236132/2 "2013-08-08T20:51:02Z")

</div>

On 2013-08-08 at 06:29 +0000, Vivek G. 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
