New in Symfony 7.1: POSIX Signals Improvements

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

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:

use SymfonyComponentProcessProcess;

$process = new Process([‚find‘, ‚/‘, ‚-name‘, ‚…‘]);
$process->setIgnoredSignals([SIGKILL, SIGUSR1]);

Handle SIGQUIT Signal in Console and Messenger

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

Sponsor the Symfony project.

Symfony Blog

Read More

Latest News


PHP 8.3.9 released!

PHP 8.2.21 released!

PHP 8.1.29 released!

Generated by Feedzy