in reply to Question On signals in perl
A signal is notification to the process of a (nominally) asynchronous event. Examples are:
INT - the process has been interrupted e.g. by ctrl/c
HUP - the attached terminal session has disconnected ("been hanged up")
PIPE - a broken pipe has been detected
TERM - synchronous termination has been requested
and so on.
A simple listing of all signal names can be found by:
The default signal handler (which generally just terminates the process as soon as it is invoked) can instead be trapped to your own code (sometimes called an AST or asynchronous system trap) by defining a routine reference as the relevant value in the %SIG hash, e.g.perl -e 'use Data::Dumper; print Dumper( \%SIG );'
or$SIG{ HUP } = \&MyNoHup;
There are some modules which also assist signal handling, including POSIX$SIG{ PIPE } = sub { warn ( "Broken pipe ignored; traceback follows:\n +" . Devel::trace() ); }
One world, one people
|
---|
In Section
Seekers of Perl Wisdom