From 4e3618e35fc5b7d65b6392384f27af71ed2bc3ca Mon Sep 17 00:00:00 2001 From: FusionPBX Date: Thu, 5 Jun 2025 16:46:39 -0600 Subject: [PATCH] Update process_exists --- app/fax_queue/resources/job/fax_send.php | 38 ++++++++++++------------ 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/app/fax_queue/resources/job/fax_send.php b/app/fax_queue/resources/job/fax_send.php index af5e3bddd1..f0c1fa556a 100644 --- a/app/fax_queue/resources/job/fax_send.php +++ b/app/fax_queue/resources/job/fax_send.php @@ -76,30 +76,30 @@ register_shutdown_function('shutdown'); //define the process id file - $pid_file = "/var/run/fusionpbx/fax_send".".".$fax_queue_uuid.".pid"; + $pid_file = '/var/run/fusionpbx/fax_send.'.$fax_queue_uuid.'.pid'; //echo "pid_file: ".$pid_file."\n"; //function to check if the process exists - function process_exists($file = false) { - - //set the default exists to false - $exists = false; - - //check to see if the process is running - if (file_exists($file)) { - $pid = file_get_contents($file); - if (posix_getsid($pid) === false) { - //process is not running - $exists = false; - } - else { - //process is running - $exists = true; - } + function process_exists($file = '') { + //check if the file exists return false if not found + if (!file_exists($file)) { + return false; } - //return the result - return $exists; + //check to see if the process id is valid + $pid = file_get_contents($file); + if (filter_var($pid, FILTER_VALIDATE_INT) === false) { + return false; + } + + //check if the process is running + exec('ps -p '.$pid, $output); + if (count($output) > 1) { + return true; + } + else { + return false; + } } //remove single quote