AbstractMigrate: do not overwrite global signal handlers

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>
This commit is contained in:
Thomas Lamprecht 2017-09-06 13:29:04 +02:00 committed by Wolfgang Bumiller
parent ea0125ae22
commit ed183bcec8

View File

@ -107,13 +107,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};
@ -146,9 +146,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