-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
Closed
Description
Symfony version(s) affected
latest
Description
- It does not make sense to dispatch a ConsoleSignalEvent after there was a ConsoleTerminateEvent.
- In case if command ran multiple times, multiple Signal events will be dispatched to the same command.
How to reproduce
Using Scheduler component, as it utilizes RunCommandMessage to subsequently run other commands.
#[AsCommand('app:test:signal')]
#[AsPeriodicTask('1 seconds')]
class SignalTestCommand extends Command implements SignalableCommandInterface
{
protected int $runCount = 0;
public function getSubscribedSignals(): array
{
return [ \SIGINT ];
}
public function handleSignal(int $signal, false|int $previousExitCode = 0): int|false
{
printf("Got signal: %d\n", $signal);
return false;
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
printf("Press Ctrl-C and you will see %d signal events\n", ++$this->runCount);
return self::SUCCESS;
}
}$ bin/console mes:consume -q scheduler_default
Press Ctrl-C and you will see 1 signal events
Press Ctrl-C and you will see 2 signal events
Press Ctrl-C and you will see 3 signal events
Press Ctrl-C and you will see 4 signal events
^CGot signal: 2
Got signal: 2
Got signal: 2
Got signal: 2Possible Solution
No response
Additional Context
No response