-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
implementing SignalableCommandInterface in standalone symfony/console might prevent SIGINT/SIGTERM #57342
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
Comments
Hey, thanks for your report! |
It's still relevant and alive. The workaround is to register all signals, that are being handled by default, which now also includes SIGQUIT: symfony/src/Symfony/Component/Console/Application.php Lines 1012 to 1018 in 0a44b87
|
Probably related. Freshly created project, with freshly created console command that's blocking on some socket operation:
CTRL+C does not work, cannot abort the command. What makes CTRL+C to work is to change |
Uh oh!
There was an error while loading. Please reload this page.
Symfony version(s) affected
6.4.8 (and probably 7.x, 6.x and before?)
Description
the documentation for signals in console claims:
However, this is not true for (at least) the standalone usage, for SIGINT and SIGTERM, when no event dispatcher is set. In these cases a signal handler is installed that does apparently prevent the default behaviour.
As is, unless also subscribing to SIGINT/SIGTERM with SignableCommandInterface and exiting in those cases, the process will keep running, since the default behaviour is prevented due to some registered handlers that don't provide the default behaviour.
Since the code hasn't changed much, I suppose this weird behaviour still exists for symfony 7+
How to reproduce
standalone usage of symfony/console with a command implementing the SignalableCommandInterface and subscribing for example to just SIGTERM. handleSignal can do whatever.
SIGINT in a standard shell (Ctrl-c) ceases to work - presuming stty is available (Terminal::hasSttyAvailable() is true), due to a handler being registered:
symfony/src/Symfony/Component/Console/Application.php
Lines 1021 to 1027 in cf4ef92
this handler obviously doesn't affect anything really and is installed if there are subscribed signals by the command but no event dispatcher is set on the application.
Possible Solution
Since it's unclear, what those handlers are for, it's unclear how to fix this in code.
The obvious workaround of subscribing to those two signals as well is error-prone (since you have to remember). Adding a warning to the documentation might also help if this (supposed) bug is not going to be fixed.
The text was updated successfully, but these errors were encountered: