Skip to content

Commit 4da1201

Browse files
authored
Merge pull request #38 from gregurco/alpine_fix
look for process id explicitly when checking if process is running
2 parents 5d58254 + 7f195aa commit 4da1201

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

Services/RabbitMqSupervisor.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,13 +197,19 @@ public function wait()
197197
*/
198198
private function isProcessRunning($pid) {
199199
$state = array();
200-
exec(sprintf('ps %d', $pid), $state);
200+
exec(sprintf('ps %d -o pid', $pid), $state);
201+
202+
// remove alignment spaces from PIDs
203+
$state = array_map('trim', $state);
201204

202205
/*
203206
* ps will return at least one row, the column labels.
204207
* If the process is running ps will return a second row with its status.
208+
*
209+
* Fix: alpine ignores PID argument and always return all processes.
210+
* Need to track if PID is not in result
205211
*/
206-
return 1 < count($state);
212+
return 1 < count($state) && in_array($pid, $state);
207213
}
208214

209215
/**

0 commit comments

Comments
 (0)