-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
Closed
Description
Symfony version(s) affected
7.3.3
Description
When using Symfony QuestionHelper and selecting input from a list of choices (ChoiceQuestion), Ctrl-C can leave the terminal in a broken state on Unixy platforms under certain conditions:
- When a signal handler is installed and calls
exit - When xdebug-handler restarts a process composer run: Ctrl+C leaves shell in a broken state composer/composer#12526
The terminal does not show any input and requires a Ctrl-Break and Enter to restart it.
When calling other QuestionHelper functions, Ctrl-C works okay.
Further info
When using a signal handler, this causes the terminal to break:
pcntl_signal(SIGINT, function ($signal) {
echo 'CRTL_C received, exiting', PHP_EOL;
exit(2;)
});But this is okay:
pcntl_signal(SIGINT, function ($signal) {
echo 'CRTL_C received - continuing', PHP_EOL;
});When using a restart, SIGINT is set to be ignored in the parent process, then set to its default action in the restarted (child) process because it inherited the ignored state.
if (!self::$inRestart) {
// Restarting, so ignore SIGINT in parent
pcntl_signal(SIGINT, SIG_IGN);
} elseif (is_int(pcntl_signal_get_handler(SIGINT))) {
// Restarted, no handler set so force default action
pcntl_signal(SIGINT, SIG_DFL);
}How to reproduce
Demo/reproducer: https://github.com/johnstevenson/sigbug
Possible Solution
Additional Context
No response