Skip to content

Commit

Permalink
Add force exit mode (double ^C)
Browse files Browse the repository at this point in the history
  • Loading branch information
roxblnfk committed Jan 24, 2024
1 parent 31fc4a0 commit 1c5b61a
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Command/Run.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
final class Run extends Command implements SignalableCommandInterface
{
private ?Application $app = null;
private bool $cancelled = false;

public function configure(): void
{
Expand Down Expand Up @@ -109,7 +110,14 @@ public function getSubscribedSignals(): array
public function handleSignal(int $signal): int|false
{
if (\defined('SIGINT') && $signal === \SIGINT) {
if ($this->cancelled) {
// Force exit
$this->app?->destroy();
return $signal;
}

$this->app?->cancel();
$this->cancelled = true;
}

if (\defined('SIGTERM') && $signal === \SIGTERM) {
Expand Down

0 comments on commit 1c5b61a

Please sign in to comment.