/** * @param int $type */ private function signalHandler($type) { if (in_array($type, [SIGHUP, SIGTERM, SIGINT])) { $this->isRunning = false; } else { if ($type === SIGCHLD) { $childrenExited = $this->processManager->processChildExited(); foreach ($childrenExited as $pid => $returnCode) { if ($returnCode !== 0) { $this->handleWorkerError(); $this->onWorkerFinished($pid, true); } else { $this->onWorkerFinished($pid, false); } if ($this->isRunning) { $this->onWorkerAvailable(); } } } else { $this->logger->info(sprintf('Unknown signal %d', $type)); } } }