Checks if a process is still running
@return boolean true if the process is still running
169104
public function isRunning()
    {
        $this->checkDirExists();

        $pidFile = $this->directory.$this->filename;
        if (!file_exists($pidFile)) {
            return false;
        }

        $pid = file_get_contents($pidFile);
        // Empty pid file means the process is not running
        if (empty($pid)) {
            return false;
        }

        if (!is_dir('/proc/'))
        {
            /* OSX Workaround, not as good as using proc dir on linux, but oh well */
            exec('ps -Ac -o pid | awk \'{print $1}\' | grep \'^'.$pid.'$\'', $output, $return);

            if ($return == 0) {
                // process with the same id is still running
                return true;
            }
        }

        /* we assume the system is a linux system here */
        if (!is_dir('/proc/'.$pid)) {
            // process with the same id is still running
            return false;
        }

        return true;
    }
448220
public function isStarted()
    {
        $started = false;
        if (version_compare(phpversion(), '5.4.0', '>=')) {
            $started = session_status() === PHP_SESSION_ACTIVE ? true : false;
        } else {
            $started = session_id() === '' ? false : true;
        }

        return $started;
    }
252678
public function isRunning()
    {
        if ($this->resourceOpen instanceof ProcOpen) {
            $status = proc_get_status($this->process);
            $running = $status['running'];
            $this->running = ($running === false) ? $running : $this->running;
        }

        return $this->running;
    }
1207581
public function isRunning() {
		if( !$this->pid ) {
			return false;
		}

		$result = shell_exec(sprintf('ps %d',
			$this->pid));
		if( count(preg_split("/\n/", $result)) > 2 ) {
			return true;
		}

		return false;
	}
1013708
public static function checkWorkerStatusForWindows()
    {
        foreach(static::$_processForWindows as $process_data)
        {
            $process = $process_data[0];
            $start_file = $process_data[1];
            $timer_id = $process_data[2];
            $status = proc_get_status($process);
            if(isset($status['running']))
            {
                if(!$status['running'])
                {
                    static::safeEcho("process $start_file terminated and try to restart\n");
                    Timer::del($timer_id);
                    proc_close($process);
                    static::forkOneWorkerForWindows($start_file);
                }
            }
            else
            {
                static::safeEcho("proc_get_status fail\n");
            }
        }
    }
867789
def is_running(self):
        
        pp = self.pid
        if pp:
            try:
                proc = psutil.Process(pp)

                # Possible status:
                # "STATUS_RUNNING", "STATUS_IDLE",
                # "STATUS_SLEEPING", "STATUS_DISK_SLEEP",
                # "STATUS_STOPPED", "STATUS_TRACING_STOP",
                # "STATUS_ZOMBIE", "STATUS_DEAD",
                # "STATUS_WAKING", "STATUS_LOCKED",

                if proc.status in (psutil.STATUS_STOPPED,
                                   psutil.STATUS_DEAD,
                                   psutil.STATUS_ZOMBIE):
                    # The PID is still in the process table so call stop to
                    # remove the PID.
                    self.stop()
                    return False
                else:
                    # OK, it's running.
                    return True

            except psutil.NoSuchProcess:
                pass
        return False
298347
def is_running(self):
        
        try:
            kill(int(self.pid.get()), 0)
            return True
        
        # Process not running, remove PID/lock file if it exists
        except:
            self.pid.remove()
            self.lock.remove()
            return False
727933
def is_running(self):
        
        try:
            return graceful_get(self.inspect(refresh=True), "State", "Running")
        except subprocess.CalledProcessError:
            return False
413437
public function monitor()
    {
        if (! $this->process->isStarted()) {
            return $this->restart();
        }

        // First, we will check to see if the supervisor failed as a duplicate and if
        // it did we will go ahead and mark it as dead. We will do this before the
        // other checks run because we do not care if this is cooling down here.
        if (! $this->process->isRunning() &&
            $this->process->getExitCode() === 13) {
            return $this->markAsDead();
        }

        // If the process is running or cooling down from a failure, we don't need to
        // attempt to do anything right now, so we can just bail out of the method
        // here and it will get checked out during the next master monitor loop.
        if ($this->process->isRunning() ||
            $this->coolingDown()) {
            return;
        }

        // Next, we will determine if the exit code is one that means this supervisor
        // should be marked as dead and not be restarted. Typically, this could be
        // an indication that the supervisor was simply purposefully terminated.
        $exitCode = $this->process->getExitCode();

        $this->markAsDead();

        // If the supervisor exited with a status code that we do not restart on then
        // we will not attempt to restart it. Otherwise, we will need to provision
        // it back out based on the latest provisioning information we have now.
        if (in_array($exitCode, $this->dontRestartOn)) {
            return;
        }

        $this->reprovision();
    }
473874
public function isSuccessful()
    {
        if (!$this->testMdSignatures()) {
            return false;
        }

        return in_array($this->getStatus(), [self::STATUS_PENDING, self::STATUS_PROCESSED]);
    }
553521
public function stopProcess()
    {
        $this->isCurrentOsSupported('Only on *nix-based systems process cna be destroyed. You are running "%s".');
        try {
            $result = shell_exec(sprintf('kill %d 2>&1', $this->pid));
            if (!preg_match('/No such process/', $result)) {
                return true;
            }
        } catch (Exception $e) {

        }

        return false;
    }
563345
public function check()
    {
        $this->notify(Status::CHECK, $this->loaded);
        $envArgs = explode('|', (string) getenv($this->envAllowXdebug));

        if (empty($envArgs[0]) && $this->requiresRestart((bool) $this->loaded)) {
            // Restart required
            $this->notify(Status::RESTART);

            if ($this->prepareRestart()) {
                $command = $this->getCommand();
                $this->notify(Status::RESTARTING, $command);
                $this->restart($command);
            }
            return;
        }

        if (self::RESTART_ID === $envArgs[0] && count($envArgs) === 5) {
            // Restarting, so unset environment variable and use saved values
            $this->notify(Status::RESTARTED);

            Process::setEnv($this->envAllowXdebug);
            self::$inRestart = true;

            if (!$this->loaded) {
                // Skipped version is only set if xdebug is not loaded
                self::$skipped = $envArgs[1];
            }

            // Put restart settings in the environment
            $this->setEnvRestartSettings($envArgs);
            return;
        }

        $this->notify(Status::NORESTART);

        if ($settings = self::getRestartSettings()) {
            // Called with existing settings, so sync our settings
            $this->syncSettings($settings);
        }
    }
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;
    }
1124568
def is_running(self) -> bool:
        """"""
        return (
            self._has_started and
            self.is_alive() or
            self.completed_at is None or
            (datetime.utcnow() - self.completed_at).total_seconds() < 0.5
        )
290586
public function stop(): bool
    {
        $this->process->getPid()->onResolve(function ($error, $pid) {
            if ($error) {
                throw new ProcessException($error);
            }

            print "\nStopping Process Id: {$pid}\n";

            if ('\\' === \DIRECTORY_SEPARATOR) {
                \exec(\sprintf('taskkill /F /T /PID %d 2>&1', $pid), $output, $exitCode);
                if ($exitCode) {
                    throw new ProcessException(\sprintf('Unable to kill the process (%s).', \implode(' ', $output)));
                }
            } else {
                $this->process->signal(15);

                if ($ok = \proc_open("kill $pid", [2 => ['pipe', 'w']], $pipes)) {
                    $ok = false === \fgets($pipes[2]);
                }

                if (!$ok) {
                    throw new ProcessException(\sprintf('Error while killing process "%s".', $pid));
                }
            }

            $this->process->kill();
        });

        return true;
    }
128497
private function checkStatus()
    {
        if (!$this->running) {
            return;
        }

        if ($this->running) {
            foreach (proc_get_status($this->resource) as $key => $value) {
                if ($key == 'command') {
                    continue;
                }

                $this->$key = $value;
            }
        }

        if (!$this->running) {
            $this->cleanup();
        }
    }
1167166
protected function runningProcesses()
    {
        $count = 0;
        foreach ($this->processes as $process) {
            if ($process->isRunning()) {
                $count++;
            }
        }

        return $count;
    }