背景
httpd.serviceの中を覗いたとき、execstopがkill -WINCH
を呼んでいるのを見つけた。
一体なぜ SIGSTOP
ではなくSIGWINCH
なのか気になった。
結論
仕様
だけど、なぜそういう仕様なのかは分からない。
環境
- CentOS7.1.503
- 3.10.0-229.el7.x86_64
- vmware player
signalの調査
まずは、man 7 signal
でSIGSTOPとSIGWINCHを見てみる。
-
SIGWINCH
はウィンドウリサイズを通知するシグナル -
SIGWINCH
はデフォルト動作が無視される。 -
SIGSTOP
はデフォルト動作が停止。
他のプロセスウィンドウリサイズを通知すると止まるのか。(止まらないはずだけど念のため)
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.
仕様!! らしいです。
仕様なら仕方ない...
なぜそういう仕様になったのかは分かりませんでした。ご存知の方がいらしたらご教授いただきたいです。