From cae1b7db89f7cc46fb611701e8d261054903a3ad Mon Sep 17 00:00:00 2001 From: thompsa Date: Fri, 12 Mar 2010 13:18:09 +1300 Subject: '\b' is not the word boundary on BSD, its actually '[[:<:]]' and '[[:>:]]', change these functions to use better syntax and not grep at all. --- etc/inc/service-utils.inc | 4 ++-- etc/inc/util.inc | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'etc') diff --git a/etc/inc/service-utils.inc b/etc/inc/service-utils.inc index 0d4c1e1..7a0eccf 100644 --- a/etc/inc/service-utils.inc +++ b/etc/inc/service-utils.inc @@ -146,7 +146,7 @@ function restart_service($name) { function is_pid_running($pidfile) { $pid = trim(file_get_contents($pidfile)); - $running = (trim(shell_exec("ps axwu | grep '\b{$pid}\b' | grep -v 'grep'")) != ''); + $running = (trim(shell_exec("ps -p {$pid}")) != ''); return $running; } @@ -195,4 +195,4 @@ function is_service_running($service, $ps = "") { } } -?> \ No newline at end of file +?> diff --git a/etc/inc/util.inc b/etc/inc/util.inc index 9bae752..686810f 100644 --- a/etc/inc/util.inc +++ b/etc/inc/util.inc @@ -50,7 +50,7 @@ function isvalidpid($pid) { } function is_process_running($process) { - $running = (trim(shell_exec("ps axwu | grep '\b{$process}\b' | grep -v 'grep'")) != ''); + $running = (shell_exec("pgrep -x {$process}") != ''); return $running; } -- cgit v1.1