Have the following in my module’s BEGIN section:
use sigtrap qw(handler shutdown normal-signals);
use sigtrap qw(die untrapped normal-signals stack-trace any error-signals);
But when sigtrap catches INT,etc.. what I get in my shutdown sub only contains the trap and not the object handle. No $self.
sub shutdown {
my $sig = shift || 'Nothing';
print "Got signal: $sig\n";
exit;
}
simply returns
Got signal: INT
My DESTROY get’s called right on time after this and has access to the object handle, but because I didn’t have access to the handle in my shutdown, I couldn’t store it and have no idea what the signal was.
I need to know what trap I got so my DESTROY method can log what caused the shutdown.
Perhaps sigtrap isn’t the best choice here. Opinions welcome.
I checked
sigtrap, it’s not specifically an OO module, if you want to use it as one, you may need to use a closure instead of an object method.So you might define your class like so:
And then call it like so: