If the process exists will return the array
else if not found will return false.

@param null $pid

@return \mozartk\ProcessFinder\Process|boolean
@throws \mozartk\ProcessFinder\Exception\ProcessFinderException
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;
    }
49294
public function kill_process($pid)
    {

        if (!is_numeric($pid)) return false;
        $pid = (int)$pid;
        $sql = "KILL $pid";

        return $this->db->query($sql);
    }
1272985
public function isProcessRunning(bool $throwsException = false): bool
    {
        $running = false;
        try {
            $pid = $this->getPid();
            $isRunning = $this->process->isRunning($pid);
            if ($isRunning) {
                $this->logger->debug("Pid '${pid}' running.");
                $running = true;
            } else {
                $this->logger->debug("Pid '${pid}' not running.");
            }
        } catch (Exception\PidNotFoundException $e) {
            if ($throwsException) {
                throw $e;
            }
        }

        return $running;
    }
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;
    }
1119537
protected function startFork($pid, $callback, Task $task, Process $oldProcess = null)
    {
        if ($pid === -1) {
            $this->cliHelper->writeTimeLine('Could not fork!');
            exit;
        } elseif ($pid) {
            $newProcess = new Process($task, $pid);
            $this->processes[$pid] = $newProcess;
        
            if ($callback !== null) {
                if ($oldProcess !== null) {
                    call_user_func($callback, $oldProcess, $newProcess);
                } else {
                    call_user_func($callback, $newProcess);
                }
            }
        } else {
            $this->executeTask($task);
        }
    }
610804
public function execute(Process $process, $name = null)
    {
        if (!is_null($name)) {
            $process->name($name);
        }
        if (!$process->isStarted()) {
            $process->start();
        }

        return array_push($this->processes, $process);
    }
830869
public function _destroy($pId)
    {
        if (! isset($this->_items[$pId])) {
            $this->_items[$pId] = Agl::getModel(self::DB_COLLECTION);
            $this->_items[$pId]->loadByRealid($pId);
        }

        if ($this->_items[$pId]->getId()) {
            $this->_items[$pId]->delete();
        }

        return true;
    }
568434
public static void killProcess(String pid) {

    //If process tree is not alive then return immediately.
    if(!ProcessTree.isAlive(pid)) {
      return;
    }
    String[] args = { "kill", "-9", pid };
    ShellCommandExecutor shexec = new ShellCommandExecutor(args);
    try {
      shexec.execute();
    } catch (IOException e) {
      LOG.warn("Error sending SIGKILL to process "+ pid + " ."+ 
          StringUtils.stringifyException(e));
    } finally {
      LOG.info("Killing process " + pid + " with SIGKILL. Exit code "
          + shexec.getExitCode());
    }
  }
1237578
private function setErrors(Process $process)
    {
        if (false === $process->isSuccessful()) {
            return $process->getErrorOutput() ?: $process->getOutput();
        }

        return null;
    }
271038
def isPIDValid(self, pid):
        
        ## Slightly copied wholesale from http://stackoverflow.com/questions/568271/how-to-check-if-there-exists-a-process-with-a-given-pid
        ## Thanks to http://stackoverflow.com/users/1777162/ntrrgc and http://stackoverflow.com/users/234270/speedplane
        class ExitCodeProcess(ctypes.Structure):
            _fields_ = [('hProcess', ctypes.c_void_p),
                        ('lpExitCode', ctypes.POINTER(ctypes.c_ulong))]
        SYNCHRONIZE = 0x100000
        PROCESS_QUERY_LIMITED_INFORMATION = 0x1000
        process = self._kernel32.OpenProcess(SYNCHRONIZE|PROCESS_QUERY_LIMITED_INFORMATION, 0, pid)
        if not process:
            return False
        ec = ExitCodeProcess()
        out = self._kernel32.GetExitCodeProcess(process, ctypes.byref(ec))
        if not out:
            err = self._kernel32.GetLastError()
            if self._kernel32.GetLastError() == 5:
                # Access is denied.
                logging.warning("Access is denied to get pid info.")
            self._kernel32.CloseHandle(process)
            return False
        elif bool(ec.lpExitCode):
            # There is an exit code, it quit
            self._kernel32.CloseHandle(process)
            return False
        # No exit code, it's running.
        self._kernel32.CloseHandle(process)
        return True
632514
public function childSignalHandler( $signo, $pid = null, $status = null )
    {
        // If no pid is provided, that means we're getting the signal from the system.  Let's figure out
        // which child process ended
        if( $pid === null )
        {
            $pid = pcntl_waitpid( -1, $status, WNOHANG );
        }

        //Make sure we get all of the exited children
        while( $pid > 0 )
        {
            if( $pid && isset( $this->currentJobs[$pid] ) )
            {
                $exitCode = pcntl_wexitstatus( $status );
                if ( $exitCode != 0 )
                {
                    $this->out->write( "Process #{$pid} of object version #".$this->currentJobs[$pid]->attribute( 'ezcontentobject_version_id' ) . " exited with status {$exitCode}" );
                    // this is required as the MySQL connection might be closed anytime by a fork
                    // this method is asynchronous, and might be triggered by any signal
                    // the only way is to use a dedicated DB connection, and close it afterwards
                    eZDB::setInstance( eZDB::instance( false, false, true ) );

                    $this->currentJobs[$pid]->reset();

                    eZDB::instance()->close();
                    eZDB::setInstance( null );
                }
                unset( $this->currentJobs[$pid] );
            }
            // A job has finished before the parent process could even note that it had been launched
            // Let's make note of it and handle it when the parent process is ready for it
            // echo "..... Adding $pid to the signal queue ..... \n";
            elseif( $pid )
            {
                $this->signalQueue[$pid] = $status;
            }
            $pid = pcntl_waitpid( -1, $status, WNOHANG );
        }
        return true;
    }
848861
private int processId(final java.lang.Process process) {
    int processId = 0;
    try {
      final Field f = process.getClass().getDeclaredField("pid");
      f.setAccessible(true);

      processId = f.getInt(process);
    } catch (final Throwable e) {
      e.printStackTrace();
    }

    return processId;
  }
133181
public function send($signal, $processId = null)
    {
        if (null === $processId) {
            $processId = posix_getpid();
        }

        return posix_kill($processId, $this->translateSignal($signal));
    }
88947
public function getPid():?int
    {
        if(isset($this->swooleProcess->pid)){
            return $this->swooleProcess->pid;
        }else{
            return null;
        }
    }
403297
protected function signal($pid, $signal)
    {
        if (function_exists('posix_kill')) {
            return posix_kill($pid, $signal);
        } else {
            system("kill -$signal $pid", $result);
            return $result === 0;
        }
    }
1175061
protected function isRunning($pid)
    {
        if (! $pid) {
            return false;
        }

        try {
            return Process::kill($pid, 0);
        } catch (Throwable $e) {
            return false;
        }
    }
1022989
private function isProcessRunning($pid)
    {
        $state = array();
        exec(sprintf('ps -o pid %d', $pid), $state);

        // remove alignment spaces from PIDs
        $state = array_map('trim', $state);

        /*
         * ps will return at least one row, the column labels.
         * If the process is running ps will return a second row with its status.
         *
         * check if pid is in that list to work even if some systems ignore the pid filter parameter
         */
        return 1 < count($state) && in_array($pid, $state);
    }