home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


8.131 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);

8.131.1 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.

8.131.2 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.

8.131.3 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 at least number .

signal

Installs a handler for any argument that looks like a signal name.

untrapped

Installs handlers only for subsequently listed signals not already trapped or ignored.