drush
drush copied to clipboard
Regression: Drush 13.3 does not properly handle SIGQUIT signal
That apparently is caused by #6124.
Here is example of a simple long running Drush command
#[AsCommand( 'example')]
final class ExampleCommand extends Command implements SignalableCommandInterface {
/**
* Signal flag.
*/
private bool $stop = FALSE;
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output): int {
for ($i = 1; $i <= 60; $i++, sleep(1)) {
echo '.';
if ($this->stop) {
echo 'Signal received...', \PHP_EOL;
sleep(5);
echo 'Done!', \PHP_EOL;
break;
}
}
return 0;
}
/**
* {@inheritdoc}
*/
public function getSubscribedSignals(): array {
return [\SIGTERM, \SIGQUIT, \SIGINT];
}
/**
* {@inheritdoc}
*/
public function handleSignal(int $signal): false|int {
$this->stop = TRUE;
return FALSE;
}
}
Start the above command and send SIGQUIT (Ctrl + \) to it.
Output Drush 13.2 (correct)
$ ./vendor/bin/drush example
....^\.Signal received!
Done!
Output Drush 13.3 (wrong)
$ ./vendor/bin/drush example
....^\.Signal received!
Quit (core dumped)
$ Done!
Note that in the last example "Done!" appears when Drush was already terminated. If a command is managed through some process manager, i.e. Supervisor, such behavior causes orphan processes.
The new way to launch Drush creates two additional shell processes besides the PHP. Also some people reported that Drush 13.3 is not working on Windows because of this change.
@Chi-teck Could you try to run ./vendor/drush/drush/drush.php directly? Just to make sure, this executable has the correct behaviour?
Yes, drush.php works correctly.
$ ./vendor/bin/drush example
.....^\.Signal received...
Quit (core dumped)
$ Done!
$ ./vendor/drush/drush/drush.php example
.....^\.Signal received...
Done!
In the original PR I implemented it without exec, because the Composer Wrapper script also works this way.
https://github.com/composer/composer/blob/main/src/Composer/Installer/BinaryInstaller.php#L409
I'm proposing reverting the bash entrypoint in #6146.
Use latest composer and Drush 13.3.1+