]> git.proxmox.com Git - qemu-server.git/commitdiff
do not overwrite global signal handlers
authorEmmanuel Kasper <e.kasper@proxmox.com>
Thu, 14 Sep 2017 13:19:39 +0000 (15:19 +0200)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Thu, 14 Sep 2017 13:25:28 +0000 (15:25 +0200)
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
PVE/QemuServer.pm
PVE/QemuServer/ImportDisk.pm

index 1002c8755bf555a7d0a44bccd216b07b8d91b505..66ffc078cd8bda1a5710ff9e31465c8813000556 100644 (file)
@@ -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;
index 2d097265bf8c6dca96d48a4c148c77b185f778a2..03e7ca415f2181a64e0206711f70e8519f1e40c3 100644 (file)
@@ -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";
index edbc20e9c60c4ec9e2c98df14d89cc5bbb9040ee..db7db6343c4c0af67a094b695d0c9e329ff80ab8 100755 (executable)
@@ -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]);