Skip to content

[Console] Remove exit() call in last SignalHandler #17805

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions components/console/events.rst
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,10 @@ Listeners receive a
use Symfony\Component\Console\Event\ConsoleSignalEvent;

$dispatcher->addListener(ConsoleEvents::SIGNAL, function (ConsoleSignalEvent $event) {

// gets the signal number
$signal = $event->getHandlingSignal();

if (\SIGINT === $signal) {
echo "bye bye!";
}
Expand Down Expand Up @@ -218,6 +218,18 @@ handle signals themselves. To do so, implement the
}
}

It is your responsibility to handle signals that are relevant to you (even
``SIGKILL``, ``SIGTERM``, etc). This allows you to ignore them or do tasks
before terminating the process for example. This behavior is intended, as
it leaves more flexibility to developers to handle each type of signal the
way they want to.

.. deprecated:: 6.3

In Symfony versions previous to 6.3, all signals (except from ``SIGUSR1`` and
``SIGUSR2``) would terminate the script by calling ``exit(0)``. From Symfony 6.3,
no more signal is automatically calling ``exit(0)``.

.. _`reserved exit codes`: https://www.tldp.org/LDP/abs/html/exitcodes.html
.. _`Signals`: https://en.wikipedia.org/wiki/Signal_(IPC)
.. _`constants of the PCNTL PHP extension`: https://www.php.net/manual/en/pcntl.constants.php