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 <d.csapak@proxmox.com>
This commit is contained in:
Dominik Csapak 2018-08-21 15:07:24 +02:00 committed by Wolfgang Bumiller
parent 3496d4bf4d
commit e03a836591

View 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;