[pve-devel] applied: [PATCH common 1/1] run_fork_with_timeout: do not overwrite global signal handlers

Wolfgang Bumiller w.bumiller at proxmox.com
Thu Sep 7 10:29:50 CEST 2017


applied

On Wed, Sep 06, 2017 at 01:29:03PM +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.
> 
> As we only send SIGINT to processes if a manual stop action gets
> triggered just catch this one here.
> 
> As this is a general method which allows to pass an arbitrary code
> payload we cannot sanely handle all signals here, so remove trapping
> all other besides SIGINT, if those need to be trapped that should be
> done by the caller on a case by case basis.
> 
> Fixes: #1495
> 
> Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
> ---
>  src/PVE/Tools.pm | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/src/PVE/Tools.pm b/src/PVE/Tools.pm
> index 90facc5..4078e50 100644
> --- a/src/PVE/Tools.pm
> +++ b/src/PVE/Tools.pm
> @@ -910,11 +910,9 @@ sub run_fork_with_timeout {
>      # disable pending alarms, save their remaining time
>      my $prev_alarm = alarm 0;
>  
> -    # trap before forking to avoid leaving a zombie if the parent get killed
> +    # avoid leaving a zombie if the parent gets interrupted
>      my $sig_received;
> -    local $SIG{INT} = $SIG{TERM} = $SIG{QUIT} = $SIG{HUP} = $SIG{PIPE} = sub {
> -	$sig_received++;
> -    };
> +    local $SIG{INT} = sub { $sig_received++; };
>  
>      my $child = fork();
>      if (!defined($child)) {
> -- 
> 2.11.0




More information about the pve-devel mailing list