Skip to content

Commit

Permalink
[Console] Handle SIGQUIT signal
Browse files Browse the repository at this point in the history
As both PHP-FPM and NGINX use SIGQUIT for graceful shutdown, I believe it's necessary PHP applications should also support it. It's especially important in cases where you run PHP application in container running php/nginx image, since they override shutdown signal that docker uses to SIGQUIT, see nginxinc/docker-nginx@3fb70dd
  • Loading branch information
ostrolucky committed Apr 6, 2024
1 parent ae16627 commit 1b84910
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public function __construct(
$this->defaultCommand = 'list';
if (\defined('SIGINT') && SignalRegistry::isSupported()) {
$this->signalRegistry = new SignalRegistry();
$this->signalsToDispatchEvent = [\SIGINT, \SIGTERM, \SIGUSR1, \SIGUSR2];
$this->signalsToDispatchEvent = [\SIGINT, \SIGQUIT, \SIGTERM, \SIGUSR1, \SIGUSR2];
}
}

Expand Down Expand Up @@ -984,7 +984,7 @@ protected function doRunCommand(Command $command, InputInterface $input, OutputI
if (Terminal::hasSttyAvailable()) {
$sttyMode = shell_exec('stty -g');

foreach ([\SIGINT, \SIGTERM] as $signal) {
foreach ([\SIGINT, \SIGQUIT, \SIGTERM] as $signal) {
$this->signalRegistry->register($signal, static fn () => shell_exec('stty '.$sttyMode));
}
}
Expand Down

0 comments on commit 1b84910

Please sign in to comment.