コード例 #1
0
 public static function deamonRunning()
 {
     $pid_file = realpath(dirname(__FILE__) . '/../../../../tmp/rfxcom.pid');
     if (!file_exists($pid_file)) {
         $pid = jeedom::retrievePidThread('rfxcmd.py');
         if ($pid != '' && is_numeric($pid)) {
             exec('kill -9 ' . $pid);
         }
         return false;
     }
     $pid = trim(file_get_contents($pid_file));
     if ($pid == '' || !is_numeric($pid)) {
         $pid = jeedom::retrievePidThread('rfxcmd.py');
         if ($pid != '' && is_numeric($pid)) {
             exec('kill -9 ' . $pid);
         }
         return false;
     }
     $result = exec('ps -p' . $pid . ' e | grep "rfxcmd" | wc -l');
     if ($result == 0) {
         unlink($pid_file);
         return false;
     }
     return true;
 }