From 20ae2bc7e8cec68bf4b753da43973b8613f5c199 Mon Sep 17 00:00:00 2001 From: sina miandashti Date: Sat, 30 Nov 2019 18:10:19 +0100 Subject: [PATCH] Update BackgroundProcess.php --- src/BackgroundProcess.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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) {