From: Dominik Csapak Date: Tue, 21 Aug 2018 13:07:24 +0000 (+0200) Subject: add readline_nointr to Tools X-Git-Url: https://git.proxmox.com/?p=pve-common.git;a=commitdiff_plain;h=e03a836591446125527230ed150669943307832b add readline_nointr to Tools this is a wrapper to have an uninterruptible readline so that we can read e.g. from a pipe even if interrupted by a signal Signed-off-by: Dominik Csapak --- diff --git a/src/PVE/Tools.pm b/src/PVE/Tools.pm index 0a7efeb..4a8b5d9 100644 --- a/src/PVE/Tools.pm +++ b/src/PVE/Tools.pm @@ -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;