From 6221c19a5b3457f98ad14e78badb07bb0be7e5c9 Mon Sep 17 00:00:00 2001 From: Marcos Mello Date: Mon, 13 Apr 2026 10:33:17 -0300 Subject: [PATCH 1/2] php-fpm.service: remove PIDFile The PIDFile directive is unnecessary for services using Type=notify (if systemd integration is enabled) or Type=simple and is discouraged by the systemd.service(5) manual. Since systemd monitors the main PID directly from the process executed in ExecStart, it does not need a PID file to track the service. Furthermore, the default configuration of php-fpm.conf has 'pid' commented out, which is equivalent to not having a PID file. Closes #21740 --- sapi/fpm/php-fpm.service.in | 1 - 1 file changed, 1 deletion(-) diff --git a/sapi/fpm/php-fpm.service.in b/sapi/fpm/php-fpm.service.in index 50a87dc555f4..82ae4d80cd36 100644 --- a/sapi/fpm/php-fpm.service.in +++ b/sapi/fpm/php-fpm.service.in @@ -8,7 +8,6 @@ After=network.target [Service] Type=@php_fpm_systemd@ -PIDFile=@EXPANDED_LOCALSTATEDIR@/run/php-fpm.pid ExecStart=@EXPANDED_SBINDIR@/php-fpm --nodaemonize --fpm-config @EXPANDED_SYSCONFDIR@/php-fpm.conf ExecReload=/bin/kill -USR2 $MAINPID From 837c9014b1c880338ffa1ae8d1d66674887df277 Mon Sep 17 00:00:00 2001 From: Marcos Mello Date: Mon, 13 Apr 2026 10:50:06 -0300 Subject: [PATCH 2/2] php-fpm.service: set KillMode=mixed Currently, php-fpm.service relies on the default KillMode=control-group, which sends SIGTERM to all processes in the cgroup simultaneously. This can interfere with php-fpm's internal process management, where the master process is designed to handle the graceful termination of its child workers. Setting KillMode=mixed ensures that SIGTERM is sent only to the master process, allowing it to orchestrate a clean shutdown. If the master process fails to exit within TimeoutStopSec, systemd will send SIGKILL to all processes in the cgroup. Additionally, if the master exits but leaves orphaned children, systemd will clean them up via SIGKILL. This mode has been supported since systemd 209 and provides a more robust shutdown sequence for master-worker architectures. Closes #18655 --- sapi/fpm/php-fpm.service.in | 1 + 1 file changed, 1 insertion(+) diff --git a/sapi/fpm/php-fpm.service.in b/sapi/fpm/php-fpm.service.in index 82ae4d80cd36..b94ce2084cb6 100644 --- a/sapi/fpm/php-fpm.service.in +++ b/sapi/fpm/php-fpm.service.in @@ -10,6 +10,7 @@ After=network.target Type=@php_fpm_systemd@ ExecStart=@EXPANDED_SBINDIR@/php-fpm --nodaemonize --fpm-config @EXPANDED_SYSCONFDIR@/php-fpm.conf ExecReload=/bin/kill -USR2 $MAINPID +KillMode=mixed # Set up a new file system namespace and mounts private /tmp and /var/tmp directories # so this service cannot access the global directories and other processes cannot