Signals are standardized messages sent to a running program to trigger specific behaviors, such as quitting or handling errors. POSIX signals are a standardized list of signals used in operating systems like Linux and macOS. In Symfony 7.1 we've made some improvements related to signals.

Allow Ignoring Signals when Running Processes

Joel Wurtz
Contributed by Joel Wurtz in #53968

Imagine that you're running a handler for Messenger component messages and you run some process (via the Process component) inside the handler. If the handler receives a SIGTERM signal (which requests the termination of the process) the handler would fail with a ProcessSignaledException instead of waiting for the process to terminate and shut down gracefully.

In Symfony 7.1 we've added a setIgnoredSignals() method so processes can define a list of signals to ignore:

1
2
3
4
use Symfony\Component\Process\Process;

$process = new Process(['find', '/', '-name', '...']);
$process->setIgnoredSignals([SIGKILL, SIGUSR1]);

Handle SIGQUIT Signal in Console and Messenger

Gabriel Ostrolucký
Contributed by Gabriel Ostrolucký in #54510

PHP-FPM and Nginx use the SIGQUIT signal for graceful shutdown. If you run your PHP application inside a Docker container and use the official PHP and nginx images, you need to handle this signal because those images override the default Docker shutdown signal to use SIGQUIT.

That's why in Symfony 7.1 we've updated the Console component to subscribe to the SIGQUIT signal in addition to the SIGINT and SIGTERM signals. The Messenger component was also updated to add SIGQUIT to the list of signals that gracefully shut down the messenger:consume and messenger:failed:retry commands.

Published in #Living on the edge