[pve-devel] applied: [PATCH guest-common 2/2] AbstractMigrate: do not overwrite global signal handlers

Wolfgang Bumiller w.bumiller at proxmox.com
Thu Sep 7 10:36:23 CEST 2017


applied to master & stable-4

On Wed, Sep 06, 2017 at 01:29:04PM +0200, Thomas Lamprecht 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.
> 
> 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 at proxmox.com>
> ---
>  PVE/AbstractMigrate.pm | 24 ++++++++++++++----------
>  1 file changed, 14 insertions(+), 10 deletions(-)
> 
> diff --git a/PVE/AbstractMigrate.pm b/PVE/AbstractMigrate.pm
> index 168014f..17fdb5d 100644
> --- a/PVE/AbstractMigrate.pm
> +++ b/PVE/AbstractMigrate.pm
> @@ -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};
> @@ -144,9 +144,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
> -- 
> 2.11.0




More information about the pve-devel mailing list