]> 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 753b3cdec4cac5edc64a251ef9f464593cb034bb..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,8 +164,12 @@ sub short_string {
            $next = $cpu;
        } else {
            $res .= ',' if length($res);
-           $res .= "$last-$next";
-           $last = $next = undef;
+           if ($last != $next) {
+               $res .= "$last-$next";
+           } else {
+               $res .= "$last";
+           }
+           $last = $next = $cpu;
        }
     }