LoginSignup
9
5

More than 5 years have passed since last update.

ApacheのGraceful StopがSIGWINCHなのは何故か

Posted at

背景

httpd.serviceの中を覗いたとき、execstopがkill -WINCHを呼んでいるのを見つけた。
一体なぜ SIGSTOPではなくSIGWINCHなのか気になった。
httpd-service.PNG

結論

仕様
だけど、なぜそういう仕様なのかは分からない。

環境

  • CentOS7.1.503
  • 3.10.0-229.el7.x86_64
  • vmware player

signalの調査

まずは、man 7 signalでSIGSTOPとSIGWINCHを見てみる。
sigstop.PNG
sigwinch.PNG

  • SIGWINCHはウィンドウリサイズを通知するシグナル
  • SIGWINCHはデフォルト動作が無視される。
  • SIGSTOPはデフォルト動作が停止。

他のプロセスウィンドウリサイズを通知すると止まるのか。(止まらないはずだけど念のため)
test2.gif

apache側の説明

The WINCH or graceful-stop signal causes the parent process to advise the children to exit after their current request (or to exit immediately if they're not serving anything).

残念ながら、なぜWINCHなのかの説明はなさそう。
Apach Doc: https://httpd.apache.org/docs/2.4/en/stopping.html

stack over flow

SOF先生に聞いてみるとこんな回答があった。

uh? if I remember correctly, SIGWINCH is a signal that get sent to a terminal application when the size of the terminal window changes (so that the application can resize itself). Typically used by ncurses applications.

なるほどncursesというアプリケーションの場合はそう言った挙動らしい。

apacheの処理をみる

gihubにあるhttpdの76行目と78行目で指定している。
commitを追ってみるとこのcommitの修正でSIGWINCHをrestartに割り当てている。(修正前はSIG_IGNなので無視されるようになっている。実装前だったから?)
その下の子プロセスが受け取った場合は何もしないけど親プロセスにgraceful restartする旨を伝えると書いてあります。

ncursesは関係ないみたいです。

SOF2

This as designed, see bz.apache.org/bugzilla/show_bug.cgi?id=50669

リンク先をみるとこう解説されています。

httpd normally runs detached from a terminal the SIGWINCH signal was chosen to instruct httpd to do a graceful shutdown. So this works as designed.

仕様!! らしいです。
仕様なら仕方ない...
なぜそういう仕様になったのかは分かりませんでした。ご存知の方がいらしたらご教授いただきたいです。

補足?
以前SIGWINCHを直接読んでたみたいですが、AP_SIG_GRACEFULに置き換わったみたいです

9
5
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
5