Aerys\WatcherProcess::collectProcessGarbage PHP Method

collectProcessGarbage() private method

private collectProcessGarbage ( )
    private function collectProcessGarbage()
    {
        foreach ($this->processes as $key => $procHandle) {
            $info = proc_get_status($procHandle);
            if ($info["running"]) {
                continue;
            }
            $this->defunctProcessCount--;
            proc_close($procHandle);
            unset($this->processes[$key]);
            if ($this->expectedFailures > 0) {
                $this->expectedFailures--;
                continue;
            }
            if (!$this->stopPromisor) {
                $this->spawn();
            }
        }
        // If we've reaped all known dead processes we can stop checking
        if (empty($this->defunctProcessCount)) {
            \Amp\disable($this->procGarbageWatcher);
        }
        if ($this->stopPromisor && empty($this->processes)) {
            \Amp\cancel($this->procGarbageWatcher);
            if ($this->stopPromisor !== true) {
                \Amp\immediately([$this->stopPromisor, "succeed"]);
            }
            $this->stopPromisor = true;
        }
    }