diff --git a/etc/inc/service-utils.inc b/etc/inc/service-utils.inc index 918d89f3b0..602eee6802 100644 --- a/etc/inc/service-utils.inc +++ b/etc/inc/service-utils.inc @@ -123,20 +123,29 @@ function restart_service($name) { } } +function is_process_running($process, $ps = "") { + if(!$ps) { + exec("/bin/ps ax | awk '{ print $5 }'", $psout); + array_shift($psout); + foreach($psout as $line) { + $ps[] = trim(array_pop(explode(' ', array_pop(explode('/', $line))))); + } + } + if(in_array($process, $ps)) { + return true; + } else { + return false; + } + return false; +} + function is_service_running($service, $ps = "") { global $config; - if(!$ps) { - exec("/bin/ps ax | awk '{ print $5 }'", $psout); - array_shift($psout); - foreach($psout as $line) { - $ps[] = trim(array_pop(explode(' ', array_pop(explode('/', $line))))); - } - } if($config['installedpackages']['service']) { foreach($config['installedpackages']['service'] as $aservice) { if($service == $aservice['name']) { if(!$aservice['executable']) return false; - if(in_array($aservice['executable'], $ps)) { + if(is_process_running($aservice['executable'], $ps)) { return true; } else { return false;