pid = (int)$processNameOrPid; } else { $this->processName = $processNameOrPid; } } /** * @see ZendDiagnostics\CheckInterface::check() */ public function check() { // TODO: make more OS agnostic if ($this->pid) { exec('ps -p ' . (int)$this->pid, $output, $return); if ($return == 1) { return new Failure(sprintf('Process with PID %s is not currently running.', $this->pid)); } } else { exec('ps -ef | grep ' . escapeshellarg($this->processName) . ' | grep -v grep', $output, $return); if ($return == 1) { return new Failure(sprintf('Could not find any running process containing "%s"', $this->processName)); } } return new Success(); } }