diff --git a/src/Dispatcher.php b/src/Dispatcher.php index ee979dc..94fd071 100644 --- a/src/Dispatcher.php +++ b/src/Dispatcher.php @@ -587,7 +587,12 @@ private function informWorkersQuit() private function waitChildren() { - while (($pid = pcntl_wait($status, WNOHANG)) > 0) { + $numWorkers = count($this->getWorkerIDs()); + for ($i = 0; $i < $numWorkers; $i++) { + $pid = pcntl_wait($status, WNOHANG); + if ($pid <= 0) { + break; + } $this->clearWorker($this->idMap[$pid] ?? '', $pid); } }