I have a Symfony Console
command that iterates over a potentially big collection of items and does a task with each of them. Since the collection can be big, the co
This is what worked for me. You need to call pcntl_signal_dispatch
before the signal handlers are actually executed. Without it, all tasks will finish first.
shouldStop = false;
foreach ( $this->tasks as $task )
{
pcntl_signal_dispatch();
if ( $this->shouldStop ) break;
$task->execute();
}
$this->showSomeStats($output);
}
public function stopCommand()
{
$this->shouldStop = true;
}
}