]> granicus.if.org Git - php/commit
Do not let PHP-FPM children miss SIGTERM, SIGQUIT
authorMaksim Nikulin <mnikulin@plesk.com>
Mon, 21 Oct 2019 07:23:29 +0000 (14:23 +0700)
committerJakub Zelenka <bukka@php.net>
Sun, 17 Nov 2019 14:46:56 +0000 (14:46 +0000)
commite37bd5dcc2e8f269c6031d86429311c8cf243060
treea3a90d67c5ed62deba4609d69aede3e85db35bf3
parent3f4a15113c50d2e86a59db8d41fb0a102f43d1c2
Do not let PHP-FPM children miss SIGTERM, SIGQUIT

Postpone signal delivery while spawning children.
Prevent the following case:

- Reload (reexec) is in progress.
- New master is forking to start enough children for pools
  where `pm` is not `on-demand`.
- Another `SIGUSR2` is received by the master process.
- Master process switches to reloading state.
- Some child has not set its own signal handlers.
- `SIGQUIT` and `SIGTERM` sent by master process are caught
  by signal handler set by master process and so they are ignored.
- A child is running, it has no reason to finish

Before pull request #4465 this scenario could cause deadlock,
however with 0ed6c37140 reload finishes after `SIGKILL`.

Use sigprocmask() around fork() to avoid race of delivery signal to children
and setting of own signal handlers.

Fixes bug #76601
sapi/fpm/fpm/fpm_children.c
sapi/fpm/fpm/fpm_main.c
sapi/fpm/fpm/fpm_signals.c
sapi/fpm/fpm/fpm_signals.h
sapi/fpm/tests/bug76601-reload-child-signals.phpt [new file with mode: 0644]