]> git.proxmox.com Git - pve-guest-common.git/commitdiff
AbstractMigrate: do not overwrite global signal handlers
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 6 Sep 2017 11:29:04 +0000 (13:29 +0200)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Thu, 7 Sep 2017 08:32:08 +0000 (10:32 +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.

This may cause weird behaviour where daemons seemingly do not get
terminating signals delivered correctly and thus may not shutdown
gracefully anymore.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
PVE/AbstractMigrate.pm

index 1efd502462d43c2ebe1f2fa69bc1112017cb4dd3..5fa17bad615addc088dfda768a71c0534de69cc4 100644 (file)
@@ -89,13 +89,13 @@ my $eval_int = sub {
     my ($self, $func, @param) = @_;
 
     eval {
-       local $SIG{INT} = $SIG{TERM} = $SIG{QUIT} = $SIG{HUP} = sub {
-           $self->{delayed_interrupt} = 0;
-           die "interrupted by signal\n";
-       };
-       local $SIG{PIPE} = sub {
-           $self->{delayed_interrupt} = 0;
-           die "interrupted by signal\n";
+       local $SIG{INT} =
+           local $SIG{TERM} =
+           local $SIG{QUIT} =
+           local $SIG{HUP} =
+           local $SIG{PIPE} = sub {
+               $self->{delayed_interrupt} = 0;
+               die "interrupted by signal\n";
        };
 
        my $di = $self->{delayed_interrupt};
@@ -147,9 +147,13 @@ sub migrate {
 
     my $starttime = time();
 
-    local $SIG{INT} = $SIG{TERM} = $SIG{QUIT} = $SIG{HUP} = $SIG{PIPE} = sub {
-       $self->log('err', "received interrupt - delayed");
-       $self->{delayed_interrupt} = 1;
+    local $SIG{INT} =
+       local $SIG{TERM} =
+       local $SIG{QUIT} =
+       local $SIG{HUP} =
+       local $SIG{PIPE} = sub {
+           $self->log('err', "received interrupt - delayed");
+           $self->{delayed_interrupt} = 1;
     };
 
     # lock container during migration