[pve-devel] applied: [PATCH common 1/2] add readline_nointr to Tools
Wolfgang Bumiller
w.bumiller at proxmox.com
Wed Aug 22 15:35:00 CEST 2018
applied
On Tue, Aug 21, 2018 at 03:07:24PM +0200, Dominik Csapak wrote:
> 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 at proxmox.com>
> ---
> src/PVE/Tools.pm | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> 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;
> --
> 2.11.0
More information about the pve-devel
mailing list