Added a catch for SIGALARM

Signed-off-by: digimer <mkelly@alteeve.ca>
main
digimer 8 months ago committed by Madison Kelly
parent 99eb177da2
commit cfa3432e78
  1. 9
      Anvil/Tools.pm

@ -194,9 +194,10 @@ sub new
$anvil->data->{ENV_VALUES}{START_TIME} = Time::HiRes::time; $anvil->data->{ENV_VALUES}{START_TIME} = Time::HiRes::time;
# Set passed parameters if needed. # Set passed parameters if needed.
my $debug = 3; my $debug = 2;
my $on_sig_int; my $on_sig_int;
my $on_sig_term; my $on_sig_term;
my $on_sig_alarm;
if (ref($parameter) eq "HASH") if (ref($parameter) eq "HASH")
{ {
# Local parameters... # Local parameters...
@ -215,6 +216,7 @@ sub new
$on_sig_int = $parameter->{on_sig_int}; $on_sig_int = $parameter->{on_sig_int};
$on_sig_term = $parameter->{on_sig_term}; $on_sig_term = $parameter->{on_sig_term};
$on_sig_alarm = $parameter->{on_sig_alarm};
} }
elsif ($parameter) elsif ($parameter)
{ {
@ -234,6 +236,11 @@ sub new
$anvil->catch_sig({signal => "TERM"}); $anvil->catch_sig({signal => "TERM"});
}; };
$SIG{ALARM} = sub {
$on_sig_term->({ debug => $debug }) if (ref($on_sig_alarm) eq "CODE");
$anvil->catch_sig({signal => "ALARM"});
};
# This sets the environment this program is running in. # This sets the environment this program is running in.
if ($ENV{SERVER_NAME}) if ($ENV{SERVER_NAME})

Loading…
Cancel
Save