DataSift\Storyplayer\OsLib\Base_Unix::getPidIsRunning PHP Метод

getPidIsRunning() публичный Метод

public getPidIsRunning ( HostDetails $hostDetails, string $pid ) : boolean
$hostDetails HostDetails
$pid string
Результат boolean
    public function getPidIsRunning($hostDetails, $pid)
    {
        // what are we doing?
        $log = usingLog()->startAction("is process PID '{$pid}' running on UNIX '{$hostDetails->hostId}'?");
        // SSH in and have a look
        $command = "ps -ef | grep '{$pid}'";
        $result = $this->runCommand($hostDetails, $command);
        // what did we find?
        if ($result->didCommandFail() || empty($result->output)) {
            $log->endAction("cannot get process list");
            return false;
        }
        // reduce down the output we have
        $pids = explode("\n", $result->output);
        $pids = FilterColumns::from($pids, "1", ' ');
        $pids = FilterForMatchingRegex::against($pids, "/^{$pid}\$/");
        // success?
        if (empty($pids)) {
            $log->endAction("not running");
            return false;
        }
        // success
        $log->endAction("is running");
        return true;
    }