]> git.proxmox.com Git - pve-common.git/blobdiff - src/PVE/CpuSet.pm
CpuSet write_to_cgroup: catch errors from close()
[pve-common.git] / src / PVE / CpuSet.pm
index 7293d9bcfe4cacfab58f0457907402c1c5433613..9f76f385d27843282cc617167b751020d88539bd 100644 (file)
@@ -82,7 +82,7 @@ sub write_to_cgroup {
 
     open(my $fh, '>', $filename) || die "failed to open '$filename' - $!\n";
     PVE::Tools::safe_print($filename, $fh, "$value\n");
-    close($fh);
+    close($fh) || die "failed to close '$filename' - $!\n";
 }
 
 sub insert {
@@ -164,7 +164,11 @@ sub short_string {
            $next = $cpu;
        } else {
            $res .= ',' if length($res);
-           $res .= "$last-$next";
+           if ($last != $next) {
+               $res .= "$last-$next";
+           } else {
+               $res .= "$last";
+           }
            $last = $next = $cpu;
        }
     }