# SIGWINCH not working on second on-the-fly binary upgrade

**URL:** <https://www.ruby-forum.com/t/sigwinch-not-working-on-second-on-the-fly-binary-upgrade/213900>\
**Category:** NGINX\
**Created:** [November 15, 2011, 5:39pm UTC](https://www.ruby-forum.com/t/sigwinch-not-working-on-second-on-the-fly-binary-upgrade/213900 "2011-11-15T17:39:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [November 15, 2011, 5:39pm UTC](https://www.ruby-forum.com/t/sigwinch-not-working-on-second-on-the-fly-binary-upgrade/213900/1 "2011-11-15T17:39:48Z")

</div>

Hi,

I was trying to upgrade nginx from 1.0.9 to 1.0.10 on-the-fly, using  
the process described on the wiki[1], but it looks like it is ignoring  
the SIGWINCH signal I send to it.

bender:~# ps ax -H | grep nginx  
31603 pts/2 S+ 0:00 grep nginx  
32606 ? S 0:00 nginx: master process  
/usr/local/nginx/sbin/nginx  
32607 ? S 9:47 nginx: worker process  
31309 ? S 0:00 nginx: master process  
/usr/local/nginx/sbin/nginx  
31310 ? S 0:00 nginx: worker process  
bender:~# kill -WINCH 32606 # 32606 is the 1.0.9 master process, 31309  
is the 1.0.10 master process  
bender:~# ps ax -H | grep nginx  
31605 pts/2 S+ 0:00 grep nginx  
32606 ? S 0:00 nginx: master process  
/usr/local/nginx/sbin/nginx  
32607 ? S 9:47 nginx: worker process  
31309 ? S 0:00 nginx: master process  
/usr/local/nginx/sbin/nginx  
31310 ? S 0:00 nginx: worker process

After a quick look at the code, it looks like this happened because  
the 1.0.9 process I am running was started during a previous  
1.0.7-\>1.0.9 on-the-fly upgrade, and the 1.0.9 master process now  
thinks it is not daemonized (ngx\_daemonized is not set on  
initialization if ngx\_inherited is set).

I have easily reproduced it by killing nginx completely, making a  
on-the-fly 1.0.10-\>1.0.10 executable upgrade twice. On the first try,  
SIGWINCH works; after the first upgrade, SIGWINCH stops working. Full  
shell session showing the bug is pasted at the end of my message.

[1]

> **[CommandLine | NGINX](https://www.nginx.com/resources/wiki/start/topics/tutorials/commandline/)**
>
> This tutorial shows you how to start, stop, and control NGINX from the command line.

–  
Eduardo

Shell session:

bender:~# ps ax -H | grep nginx  
31678 pts/2 S+ 0:00 script -t -a /tmp/nginx.script  
31679 pts/2 S+ 0:00 script -t -a /tmp/nginx.script  
31684 pts/5 S+ 0:00 grep nginx  
bender:~# /usr/local/nginx/sbin/nginx  
bender:~# ps ax -H | grep nginx  
31678 pts/2 S+ 0:00 script -t -a /tmp/nginx.script  
31679 pts/2 S+ 0:00 script -t -a /tmp/nginx.script  
31689 pts/5 S+ 0:00 grep nginx  
31686 ? Ss 0:00 nginx: master process  
/usr/local/nginx/sbin/nginx  
31687 ? S 0:00 nginx: worker process  
bender:~# kill -USR2 31686  
bender:~# ps ax -H | grep nginx  
31678 pts/2 S+ 0:00 script -t -a /tmp/nginx.script  
31679 pts/2 S+ 0:00 script -t -a /tmp/nginx.script  
31693 pts/5 S+ 0:00 grep nginx  
31686 ? Ss 0:00 nginx: master process  
/usr/local/nginx/sbin/nginx  
31687 ? S 0:00 nginx: worker process  
31690 ? S 0:00 nginx: master process  
/usr/local/nginx/sbin/nginx  
31691 ? S 0:00 nginx: worker process  
bender:~# kill -WINCH 31686  
bender:~# ps ax -H | grep nginx  
31678 pts/2 S+ 0:00 script -t -a /tmp/nginx.script  
31679 pts/2 S+ 0:00 script -t -a /tmp/nginx.script  
31695 pts/5 S+ 0:00 grep nginx  
31686 ? Ss 0:00 nginx: master process  
/usr/local/nginx/sbin/nginx  
31690 ? S 0:00 nginx: master process  
/usr/local/nginx/sbin/nginx  
31691 ? S 0:00 nginx: worker process  
bender:~# echo SIGWINCH worked on the first process  
SIGWINCH worked on the first process  
bender:~# kill -QUIT 31686  
bender:~# ps ax -H | grep nginx  
31678 pts/2 S+ 0:00 script -t -a /tmp/nginx.script  
31679 pts/2 S+ 0:00 script -t -a /tmp/nginx.script  
31697 pts/5 S+ 0:00 grep nginx  
31690 ? S 0:00 nginx: master process  
/usr/local/nginx/sbin/nginx  
31691 ? S 0:00 nginx: worker process  
bender:~# kill -USR2 31690  
bender:~# ps ax -H | grep nginx  
31678 pts/2 S+ 0:00 script -t -a /tmp/nginx.script  
31679 pts/2 S+ 0:00 script -t -a /tmp/nginx.script  
31705 pts/5 S+ 0:00 grep nginx  
31690 ? S 0:00 nginx: master process  
/usr/local/nginx/sbin/nginx  
31691 ? S 0:00 nginx: worker process  
31702 ? S 0:00 nginx: master process  
/usr/local/nginx/sbin/nginx  
31703 ? S 0:00 nginx: worker process  
bender:~# kill -WINCH 31690  
bender:~# ps ax -H | grep nginx  
31678 pts/2 S+ 0:00 script -t -a /tmp/nginx.script  
31679 pts/2 S+ 0:00 script -t -a /tmp/nginx.script  
31709 pts/5 S+ 0:00 grep nginx  
31690 ? S 0:00 nginx: master process  
/usr/local/nginx/sbin/nginx  
31691 ? S 0:00 nginx: worker process  
31702 ? S 0:00 nginx: master process  
/usr/local/nginx/sbin/nginx  
31703 ? S 0:00 nginx: worker process  
bender:~# kill -WINCH 31690  
bender:~# ps ax -H | grep nginx  
31678 pts/2 S+ 0:00 script -t -a /tmp/nginx.script  
31679 pts/2 S+ 0:00 script -t -a /tmp/nginx.script  
31711 pts/5 S+ 0:00 grep nginx  
31690 ? S 0:00 nginx: master process  
/usr/local/nginx/sbin/nginx  
31691 ? S 0:00 nginx: worker process  
31702 ? S 0:00 nginx: master process  
/usr/local/nginx/sbin/nginx  
31703 ? S 0:00 nginx: worker process  
bender:~# echo PID 31690 is ignoring SIGWINCH signals  
PID 31690 is ignoring SIGWINCH signals  
bender:~# kill -QUIT 31690  
bender:~# ps ax -H | grep nginx  
31678 pts/2 S+ 0:00 script -t -a /tmp/nginx.script  
31679 pts/2 S+ 0:00 script -t -a /tmp/nginx.script  
31713 pts/5 S+ 0:00 grep nginx  
31702 ? S 0:00 nginx: master process  
/usr/local/nginx/sbin/nginx  
31703 ? S 0:00 nginx: worker process

---

<div class="post-metadata">

**Author:** ![Eduardo\_Habkost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/90db22/32.png) [@Eduardo\_Habkost](https://www.ruby-forum.com/u/Eduardo_Habkost)\
**Post date:** [November 15, 2011, 5:41pm UTC](https://www.ruby-forum.com/t/sigwinch-not-working-on-second-on-the-fly-binary-upgrade/213900/2 "2011-11-15T17:41:03Z")

</div>

Nice find, I think I was experiencing a similar issue with upgrading on  
the  
fly from 1.1.7 to 1.1.9.

On Tue, Nov 15, 2011 at 11:38 AM, Eduardo Habkost  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)wrote:

> 32607 ? S 9:47 nginx: worker process  
> 31309 ? S 0:00 nginx: master process  
> on-the-fly 1.0.10-\>1.0.10 executable upgrade twice. On the first try,
> 
> /usr/local/nginx/sbin/nginx  
> /usr/local/nginx/sbin/nginx  
> 31691 ? S 0:00 nginx: worker process  
> bender:~# kill -USR2 31690  
> bender:~# kill -WINCH 31690  
> bender:~# kill -WINCH 31690  
> bender:~# echo PID 31690 is ignoring SIGWINCH signals
> 
> * * *
> 
> nginx mailing list  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> [mailman.nginx.org archive](http://mailman.nginx.org/mailman/listinfo/nginx)

–

Ilan B.  
Chief Technology Officer

> **[Online Homeschool Curriculum from Time4Learning](https://www.time4learning.com/)**
>
> PreK-12 homeschooling is EASY with Time4Learning at your fingertips with award-winning online lessons, and parent-friendly planning and reporting tools.

6300 NE 1st Ave., Suite 203  
Ft. Lauderdale, FL 33334  
(954) 771-0914

[http://www.twitter.com/time4learning](http://www.twitter.com/time4learning)  
[http://www.facebook.com/Time4Learning](http://www.facebook.com/Time4Learning)

[Time4Learning.com](http://Time4Learning.com) - Online interactive curriculum for home use, PreK-8th  
Grade.  
[Time4Writing.com](http://Time4Writing.com) - Online writing tutorials for high, middle, and  
elementary school students.  
[Time4Learning.net](http://Time4Learning.net) - A forum to chat with parents online about kids,  
education, parenting and more.  
[spellingcity.com](http://spellingcity.com) - Online vocabulary and spelling activities for  
teachers,  
parents and students.

---

<div class="post-metadata">

**Author:** ![Eduardo\_Habkost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/90db22/32.png) [@Eduardo\_Habkost](https://www.ruby-forum.com/u/Eduardo_Habkost)\
**Post date:** [November 15, 2011, 5:43pm UTC](https://www.ruby-forum.com/t/sigwinch-not-working-on-second-on-the-fly-binary-upgrade/213900/3 "2011-11-15T17:43:32Z")

</div>

Verified here as well, I am upgrading by sending QUIT to the old master  
process as WINCH does not work.

Boyko

---

<div class="post-metadata">

**Author:** ![Eduardo\_Habkost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/90db22/32.png) [@Eduardo\_Habkost](https://www.ruby-forum.com/u/Eduardo_Habkost)\
**Post date:** [November 15, 2011, 5:41pm UTC](https://www.ruby-forum.com/t/sigwinch-not-working-on-second-on-the-fly-binary-upgrade/213900/4 "2011-11-15T17:41:40Z")

</div>

I mean 1.1.8.

On Tue, Nov 15, 2011 at 11:40 AM, Ilan B.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)wrote:

> > the SIGWINCH signal I send to it.  
> > is the 1.0.10 master process  
> > the 1.0.9 process I am running was started during a previous  
> > [GitHub - nginxinc/nginx-wiki: ARCHIVED -- Source for the now archived NGINX Wiki section of https://www.nginx.com · GitHub](http://wiki.nginx.org/CommandLine#Upgrading_To_a_New_Binary_On_The_Fly)  
> > 31684 pts/5 S+ 0:00 grep nginx  
> > 31678 pts/2 S+ 0:00 script -t -a /tmp/nginx.script  
> > 31678 pts/2 S+ 0:00 script -t -a /tmp/nginx.script  
> > bender:~# ps ax -H | grep nginx  
> > 31705 pts/5 S+ 0:00 grep nginx  
> > 31709 pts/5 S+ 0:00 grep nginx  
> > 31711 pts/5 S+ 0:00 grep nginx  
> > 31678 pts/2 S+ 0:00 script -t -a /tmp/nginx.script
> 
> Ft. Lauderdale, FL 33334  
> education, parenting and more.  
> [spellingcity.com](http://spellingcity.com) - Online vocabulary and spelling activities for  
> teachers, parents and students.

–

Ilan B.  
Chief Technology Officer

> **[Online Homeschool Curriculum from Time4Learning](https://www.time4learning.com/)**
>
> PreK-12 homeschooling is EASY with Time4Learning at your fingertips with award-winning online lessons, and parent-friendly planning and reporting tools.

6300 NE 1st Ave., Suite 203  
Ft. Lauderdale, FL 33334  
(954) 771-0914

[http://www.twitter.com/time4learning](http://www.twitter.com/time4learning)  
[http://www.facebook.com/Time4Learning](http://www.facebook.com/Time4Learning)

[Time4Learning.com](http://Time4Learning.com) - Online interactive curriculum for home use, PreK-8th  
Grade.  
[Time4Writing.com](http://Time4Writing.com) - Online writing tutorials for high, middle, and  
elementary school students.  
[Time4Learning.net](http://Time4Learning.net) - A forum to chat with parents online about kids,  
education, parenting and more.  
[spellingcity.com](http://spellingcity.com) - Online vocabulary and spelling activities for  
teachers,  
parents and students.

---

<div class="post-metadata">

**Author:** ![Eduardo\_Habkost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/90db22/32.png) [@Eduardo\_Habkost](https://www.ruby-forum.com/u/Eduardo_Habkost)\
**Post date:** [November 15, 2011, 6:56pm UTC](https://www.ruby-forum.com/t/sigwinch-not-working-on-second-on-the-fly-binary-upgrade/213900/5 "2011-11-15T18:56:33Z")

</div>

Hello!

On Tue, Nov 15, 2011 at 02:38:31PM -0200, Eduardo Habkost wrote:

> I was trying to upgrade nginx from 1.0.9 to 1.0.10 on-the-fly, using  
> the process described on the wiki[1], but it looks like it is ignoring  
> the SIGWINCH signal I send to it.

[…]

> After a quick look at the code, it looks like this happened because  
> the 1.0.9 process I am running was started during a previous  
> 1.0.7-\>1.0.9 on-the-fly upgrade, and the 1.0.9 master process now  
> thinks it is not daemonized (ngx\_daemonized is not set on  
> initialization if ngx\_inherited is set).
> 
> I have easily reproduced it by killing nginx completely, making a  
> on-the-fly 1.0.10-\>1.0.10 executable upgrade twice. On the first try,  
> SIGWINCH works; after the first upgrade, SIGWINCH stops working. Full  
> shell session showing the bug is pasted at the end of my message.

Yes, thank you, this is a bug introduced in 1.1.1/1.0.9.

As a workaround SIGQUIT to old master process may be used (it  
doesn’t allow to revive old master, but allow upgrade).

The following patch should fix this:

diff --git a/src/core/nginx.c b/src/core/nginx.c  
— a/src/core/nginx.c  
+++ b/src/core/nginx.c  
@@ -374,6 +374,10 @@ main(int argc, char \*const \*argv)  
ngx\_daemonized = 1;  
}

- if (ngx\_inherited) {
- 

```
   ngx_daemonized = 1;

```

- }
- 

#endif

```
 if (ngx_create_pidfile(&ccf->pid, cycle->log) != NGX_OK) {

```

Maxim D.
