]> git.proxmox.com Git - pve-common.git/blobdiff - src/PVE/Tools.pm
add readline_nointr to Tools
[pve-common.git] / src / PVE / Tools.pm
index 0a7efeb8dce920d1904d651b66d1b20234ff1e46..4a8b5d9b530521af9c6a033da6ad2a4952e5bc07 100644 (file)
@@ -1596,4 +1596,16 @@ sub convert_size {
     return int($value);
 }
 
+# uninterruptible readline
+# retries on EINTR
+sub readline_nointr {
+    my ($fh) = @_;
+    my $line;
+    while (1) {
+       $line = <$fh>;
+       last if defined($line) || ($! != EINTR);
+    }
+    return $line;
+}
+
 1;