projects
/
pve-common.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
3496d4b
)
add readline_nointr to Tools
author
Dominik Csapak
<d.csapak@proxmox.com>
Tue, 21 Aug 2018 13:07:24 +0000
(15:07 +0200)
committer
Wolfgang Bumiller
<w.bumiller@proxmox.com>
Wed, 22 Aug 2018 13:32:56 +0000
(15:32 +0200)
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>
src/PVE/Tools.pm
patch
|
blob
|
blame
|
history
diff --git
a/src/PVE/Tools.pm
b/src/PVE/Tools.pm
index 0a7efeb8dce920d1904d651b66d1b20234ff1e46..4a8b5d9b530521af9c6a033da6ad2a4952e5bc07 100644
(file)
--- 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;