Get pid.

@return int|null
341362
protected function getCurrentPid()
    {
        if ($this->currentPid) {
            return $this->currentPid;
        }

        $path = $this->getPidPath();

        return $this->currentPid = file_exists($path)
            ? (int) file_get_contents($path) ?? $this->removePidFile()
            : null;
    }
110957
public function extractId() {
        $regex = '/[\'"]id[\'"] *: *([0-9]*)/';
        $rawData = $this->getRawPostData();
        if (preg_match($regex, $rawData, $m)) {
            return intval($m[1]);
        } else {
            return null;
        }
    }
654512
public function getPidLoadInfo($pid)
    {
        $commandsDto = new CommandsExecutionDto();
        $commandsDto->setCommandName(CommandsConstants::GET_PID_LOAD_INFO);
        $commandsDto->setPid($pid);

        return $this->getCommandExecutionResult($commandsDto);
    }
877900
protected function _getPid()
    {
        if (!file_exists($this->_pidFile)) {
            return false;
        }
        return (($this->_pid = file_get_contents($this->_pidFile)) && posix_kill($this->_pid, 0)) ? $this->_pid : false;
    }
750097
private function getSupervisorPid()
    {
        $pidPath = $this->paths['pid_file'];

        $pid = null;
        if (is_file($pidPath) && is_readable($pidPath)) {
            $pid = (int)file_get_contents($pidPath);
        }

        return $pid;
    }
1182145
private int getPid() {

	PageContext pc = ThreadLocalPageContext.get();
	if (pc == null) {
	    pc = CFMLEngineFactory.getInstance().getThreadPageContext();
	    if (pc == null) throw new RuntimeException("cannot get pid for current thread");
	}
	return pc.getId();
    }
81153
public function getPid()
    {
        $options = static::getOptions();
        $debug = @$options['debug'] === true;

        $pidFile = $options['pid_file'];
        if (!$pidFile)
            throw new \Exception("No pid_file in the config");

        $fpPid = fopen($pidFile, "c");
        if (!$fpPid)
            throw new \Exception("Could not open " . $pidFile);

        if (!flock($fpPid, LOCK_EX | LOCK_NB)) {
            fclose($fpPid);
            return (int)file_get_contents($pidFile);
        }

        flock($fpPid, LOCK_UN);
        fclose($fpPid);
        @unlink($pidFile);
        return false;
    }
1103387
public function isRunning($pid)
    {
        $output = $exitCode = null;
        exec(sprintf("ps %d", $pid), $output, $exitCode);
        return $exitCode === 0;
    }
1243486
public long getPID() {
		long currentPID = cachedPID.get();
		if (currentPID != 0) {
			return currentPID;
		}
		try {
			currentPID = detectPID();
		} catch (Throwable cause) {
			logger.info("Unable to detect process ID!", cause);
		}
		if (currentPID == 0) {
			currentPID = System.nanoTime();
			if (!cachedPID.compareAndSet(0, currentPID)) {
				currentPID = cachedPID.get();
			}
		} else {
			cachedPID.set(currentPID);
		}
		return currentPID;
	}
1275637
function getByPID(pid) {
  var workers = get();
  var i;
  var worker;

  for (i = 0; i < workers.length; i++) {
    worker = workers[i];
    if (worker.pid === pid) {
      return worker;
    }
  }
  // else return undefined
}
1332313
def _get_shell_pid():
    """"""
    proc = Process(os.getpid())

    try:
        return proc.parent().pid
    except TypeError:
        return proc.parent.pid
211130
public function start(): int
    {
        $scripts = $this->installManager->install();

        $this->processRunner = new ProcessRunner($scripts->getMockService(), $this->getArguments());

        $processId =  $this->processRunner->run();

        $this->verifyHealthCheck();

        return $processId;
    }
248536
public function getProcessId()
    {
        if (null === $this->processId) {
            $content = fgets($this->getFileResource());
            $pieces = explode(PHP_EOL, trim($content));
            $this->processId = reset($pieces) ?: 0;
        }

        return $this->processId ?: null;
    }
52736
public function wait($pid = null)
    {
        if ($pid) {
            $threads = [$pid];
        } else {
            $threads = $this->threads;
        }

        $error = false;
        $status = 0;
        foreach ($threads as $pid) {
            pcntl_waitpid($pid, $status);
            if ($status > 0) {
                $error = $status;
            }
            unset($this->threads[$pid]);
        }

        if (!$this->ignoreErrors && $error) {
            $memory = shmop_open($this->memoryKey, "a", 0, 0);
            $errors = shmop_read($memory, 0, static::SHARED_MEMORY_LIMIT);
            shmop_delete($memory);
            shmop_close($memory);

            $error = "An error occurred within a thread, the return code was (" . $error . ")";
            if ($errors = trim($errors)) {
                $error .= "\n" . $errors;
            }
            throw new \Exception($error);
        }

        return $status;
    }
515820
public function getProcess($pid = null)
    {
        if (is_null($pid)) {
            $pid = $this->pid;
        }

        if (is_null($pid)) {
            throw new ProcessFinderException('Pid is required');
        }

        $process = $this->api->getProcessByPid($pid);

        return count($process) ? $process[0] : false;
    }
1120007
public function getPidfile()
    {
        $resource = false;

        if (isset($this->pidfile) && is_readable($this->pidfile)) {
            $resource = fopen($this->pidfile, 'r');
        }

        return $resource ? $resource : null;
    }
351693
public function getPID()
    {
        $id = (string) $this->objectID;

        // PID is stored as little-endian, flip it around
        $pid = substr($id, 16, 2) . substr($id, 14, 2);
        return hexdec($pid);
    }