public function run() { $attempts = 0; while (true) { $attempts += 1; $lastWill = new LastWill($this->options); $pid = pcntl_fork(); if ($pid >= 0) { if ($pid) { $this->catchAndForwardSignalTo($pid); $status = $this->waitUntilProcessDiesAndReturnStatus($pid); $lastWill->stop(); list($tryAnotherTime, $result) = $this->afterChildDeathWithStatus($this->exitStatusOfLastChild($status), $attempts, $lastWill); if (!$tryAnotherTime) { return $result; } } else { $life = new Life($attempts); $this->catchSignalsFor($life); $lastWill->capture(); return call_user_func($this->main, $life); } } } }