]> git.mxchange.org Git - friendica.git/commitdiff
Check the readability before acessing /proc/loadavg
authorMichael <heluecht@pirati.ca>
Tue, 18 Oct 2022 08:02:55 +0000 (08:02 +0000)
committerMichael <heluecht@pirati.ca>
Tue, 18 Oct 2022 08:02:55 +0000 (08:02 +0000)
src/Core/System.php

index 0c1e499d939395ac82ec2c5a05451d9873da95a1..8a8f273a8db7fdf2c9ef5402f22a4e19899f20fa 100644 (file)
@@ -442,10 +442,13 @@ class System
         */
        public static function getLoadAvg(): array
        {
-               $content = @file_get_contents('/proc/loadavg');
-               if (empty($content)) {
-                       $content = shell_exec('cat /proc/loadavg');
+               if (is_readable('/proc/loadavg')) {
+                       $content = @file_get_contents('/proc/loadavg');
+                       if (empty($content)) {
+                               $content = shell_exec('cat /proc/loadavg');
+                       }
                }
+
                if (empty($content) || !preg_match("#([.\d]+)\s([.\d]+)\s([.\d]+)\s(\d+)/(\d+)#", $content, $matches)) {
                        $load_arr = sys_getloadavg();
                        if (empty($load_arr)) {