From c4594e364ee820ba17d1b5369587c4c2071045e9 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Sun, 6 Jan 2013 21:07:47 +0545 Subject: Prevent no such file message when pid file does not exist --- etc/inc/util.inc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'etc/inc/util.inc') diff --git a/etc/inc/util.inc b/etc/inc/util.inc index 1e5fb79..858d663 100644 --- a/etc/inc/util.inc +++ b/etc/inc/util.inc @@ -41,11 +41,13 @@ function killbypid($pidfile) { return sigkillbypid($pidfile, "TERM"); } -function isvalidpid($pid) { +function isvalidpid($pidfile) { $output = ""; - exec("/bin/pgrep -nF {$pid}", $output, $retval); - - return (intval($retval) == 0); + if (file_exists($pidfile)) { + exec("/bin/pgrep -nF {$pidfile}", $output, $retval); + return (intval($retval) == 0); + } + return false; } function is_process_running($process) { -- cgit v1.1