From 894aaa1032a95da0a27f6d01d6a0be2ca099b667 Mon Sep 17 00:00:00 2001 From: Jacques Marneweck Date: Mon, 9 May 2016 07:31:16 +0200 Subject: [PATCH] Fixes for SmartOS / Solaris --- lib/Resque/Worker.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/Resque/Worker.php b/lib/Resque/Worker.php index 0ba86d9a..e0f1f82b 100644 --- a/lib/Resque/Worker.php +++ b/lib/Resque/Worker.php @@ -410,7 +410,13 @@ public function killChild() } $this->logger->log(Psr\Log\LogLevel::INFO, 'Killing child at {child}', array('child' => $this->child)); - if(exec('ps -o pid,state -p ' . $this->child, $output, $returnCode) && $returnCode != 1) { + if ('SunOS' == PHP_OS) { + $cmd = 'ps -o pid,s -p'; + } else { + $cmd = 'ps -o pid,state -p'; + } + + if(exec($cmd . ' ' . $this->child, $output, $returnCode) && $returnCode != 1) { $this->logger->log(Psr\Log\LogLevel::DEBUG, 'Child {child} found, killing.', array('child' => $this->child)); posix_kill($this->child, SIGKILL); $this->child = null; @@ -454,7 +460,14 @@ public function pruneDeadWorkers() public function workerPids() { $pids = array(); - exec('ps -A -o pid,command | grep [r]esque', $cmdOutput); + + if ('SunOS' == PHP_OS) { + $cmd = 'ps -A -o pid,comm'; + } else { + $cmd = 'ps -A -o pid,command'; + } + + exec($cmd . ' | grep [r]esque', $cmdOutput); foreach($cmdOutput as $line) { list($pids[],) = explode(' ', trim($line), 2); }