diff --git a/src/BackgroundProcess.php b/src/BackgroundProcess.php index 599265c..052ba95 100755 --- a/src/BackgroundProcess.php +++ b/src/BackgroundProcess.php @@ -94,8 +94,9 @@ public function isRunning() 'systems, such as Unix, Linux or Mac OS X. You are running "%s".'); try { - $result = shell_exec(sprintf('ps %d 2>&1', $this->pid)); - if (count(preg_split("/\n/", $result)) > 2 && !preg_match('/ERROR: Process ID out of range/', $result)) { + $result = shell_exec("ps -ef | awk '{print $1}'"); + $pidArray = explode(PHP_EOL, $result); + if (in_array($this->pid,$pidArray) && !preg_match('/ERROR: Process ID out of range/', $result)) { return true; } } catch (Exception $e) {