[pve-devel] applied: [PATCH qemu-server 1/1] do not overwrite global signal handlers
Wolfgang Bumiller
w.bumiller at proxmox.com
Thu Sep 14 15:28:06 CEST 2017
applied
On Thu, Sep 14, 2017 at 03:19:39PM +0200, Emmanuel Kasper wrote:
> perls 'local' must be either used in front of each $SIG{...}
> assignments or they must be put in a list, else it affects only the
> first variable and the rest are *not* in local context.
>
> In all cases the global signal handlers we overwrote were in cli programs or
> forked workers, not in daemons.
> ---
> PVE/API2/Qemu.pm | 5 ++++-
> PVE/QemuServer.pm | 23 ++++++++++++++---------
> PVE/QemuServer/ImportDisk.pm | 8 +++++---
> 3 files changed, 23 insertions(+), 13 deletions(-)
>
> diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
> index 1002c87..66ffc07 100644
> --- a/PVE/API2/Qemu.pm
> +++ b/PVE/API2/Qemu.pm
> @@ -2697,7 +2697,10 @@ __PACKAGE__->register_method({
> my $newvollist = [];
>
> eval {
> - local $SIG{INT} = $SIG{TERM} = $SIG{QUIT} = $SIG{HUP} = sub { die "interrupted by signal\n"; };
> + local $SIG{INT} =
> + local $SIG{TERM} =
> + local $SIG{QUIT} =
> + local $SIG{HUP} = sub { die "interrupted by signal\n"; };
>
> warn "moving disk with snapshots, snapshots will not be moved!\n"
> if $snapshotted;
> diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
> index 2d09726..03e7ca4 100644
> --- a/PVE/QemuServer.pm
> +++ b/PVE/QemuServer.pm
> @@ -5622,9 +5622,11 @@ sub restore_vma_archive {
>
> eval {
> # enable interrupts
> - local $SIG{INT} = $SIG{TERM} = $SIG{QUIT} = $SIG{HUP} = $SIG{PIPE} = sub {
> - die "interrupted by signal\n";
> - };
> + local $SIG{INT} =
> + local $SIG{TERM} =
> + local $SIG{QUIT} =
> + local $SIG{HUP} =
> + local $SIG{PIPE} = sub { die "interrupted by signal\n"; };
> local $SIG{ALRM} = sub { die "got timeout\n"; };
>
> $oldtimeout = alarm($timeout);
> @@ -5738,15 +5740,18 @@ sub restore_tar_archive {
> my $tmpfn = "$conffile.$$.tmp";
>
> # disable interrupts (always do cleanups)
> - local $SIG{INT} = $SIG{TERM} = $SIG{QUIT} = $SIG{HUP} = sub {
> - print STDERR "got interrupt - ignored\n";
> - };
> + local $SIG{INT} =
> + local $SIG{TERM} =
> + local $SIG{QUIT} =
> + local $SIG{HUP} = sub { print STDERR "got interrupt - ignored\n"; };
>
> eval {
> # enable interrupts
> - local $SIG{INT} = $SIG{TERM} = $SIG{QUIT} = $SIG{HUP} = $SIG{PIPE} = sub {
> - die "interrupted by signal\n";
> - };
> + local $SIG{INT} =
> + local $SIG{TERM} =
> + local $SIG{QUIT} =
> + local $SIG{HUP} =
> + local $SIG{PIPE} = sub { die "interrupted by signal\n"; };
>
> if ($archive eq '-') {
> print "extracting archive from STDIN\n";
> diff --git a/PVE/QemuServer/ImportDisk.pm b/PVE/QemuServer/ImportDisk.pm
> index edbc20e..db7db63 100755
> --- a/PVE/QemuServer/ImportDisk.pm
> +++ b/PVE/QemuServer/ImportDisk.pm
> @@ -82,9 +82,11 @@ sub do_import {
>
> eval {
> # trap interrupts so we have a chance to clean up
> - local $SIG{INT} = $SIG{TERM} = $SIG{QUIT} = $SIG{HUP} = $SIG{PIPE} = sub {
> - die "interrupted by signal\n";
> - };
> + local $SIG{INT} =
> + local $SIG{TERM} =
> + local $SIG{QUIT} =
> + local $SIG{HUP} =
> + local $SIG{PIPE} = sub { die "interrupted by signal\n"; };
> PVE::Storage::activate_volumes($storecfg, [$dst_volid]);
> run_command($convert_command);
> PVE::Storage::deactivate_volumes($storecfg, [$dst_volid]);
> --
> 2.11.0
More information about the pve-devel
mailing list