Sys::Signal - Set signal handlers with restoration of existing C sighandler
use Sys::Signal (); eval { my $h = Sys::Signal->set(ALRM => sub { die "timeout\n" }); alarm $timeout; ... do something thay may timeout ... alarm 0; }; die $@ if $@;
The Sys::Signal set method works much like local $SIG{FOO}, but with the added functionality of restoring the underlying signal handler to the previous C function, rather than Perl's. Unless, of course, Perl's C signal handler was the previous handler.
local $SIG{FOO}
Doug MacEachern
perl(1).
To install Sys::Signal, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Sys::Signal
CPAN shell
perl -MCPAN -e shell install Sys::Signal
For more information on module installation, please visit the detailed CPAN module installation guide.