sigtrap
Pragma to enable simple signal handling. Provides two signal handlers that can be installed, or you can install your own handler; also provides options to specify which signals to trap. Ignores requests to trap signals not used in your system’s architecture.
use sigtrap; # initialize default signal handlers use sigtrap qw(die normal-signals); use sigtrap 'handler' => \handlername, 'normal-signals'; use sigtrap qw(handler handlername normal-signals stack-trace error-signals);
Signal Handler Options
Used to specify which handler is to be installed and used for signals installed after the handler:
-
die
Installs handler that
die
s with a message indicating what signal was trapped.-
handler
handlername
Installs your handler
handlername
.-
stack-trace
Default signal handler. Outputs stack trace to STDERR and tries to dump core.
Signal List Options
You can specify your own list of options:
use sigtrap qw(BUS SEGV PIPE ABRT);
or use one of the following built-in option lists:
-
error-signals
Signals that indicate a serious problem: ABRT, BUS, EMT, FPE, ILL, QUIT, SEGV, SYS, and TRAP.
-
normal-signals
Signals a program is most likely to encounter: HUP, INT, PIPE, and TERM.
-
old-interface-signals
Default. Signals trapped by default in older versions of
sigtrap
: ABRT, BUS, EMT, FPE, ILL, PIPE, QUIT, SEGV, SYS, TERM, and TRAP.
Other Options
-
any
Installs handlers only for subsequently listed signals that aren’t already taken care of.
-
number
Requires that the version of
sigtrap
being used must be ...
Get Perl in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.