Signal::Unsafe - Unsafe signal handlers made convenient
version 0.006
$Signal::Mask{USR1} = 1; $Signal::Unsafe{USR1} = sub { my ($signo, $args, $binary) = @_; die "Process $args->{int} has run too long"; } for my $pid (@pids) { my $clock = POSIX::RT::Clock->get_cpuclock($pid); push @timers, POSIX::RT::Timer->new(clock => $clock, value => 180, id => $pid); } $ppoll = IO::PPoll->new(); $ppoll->mask(\*STDIN, POLLIN); # SIGUSR1 may be received during the ppoll, but not outside of it $ppoll->poll;
This module provides a single global hash that, much like %SIG, allows one to set signal handlers. Unlike %SIG, it will set "unsafe" ones. You're expected to provide your own safety, for example by masking and then selectively unmasking it as in the synopsis.
%SIG
%Signal::Unsafe
This hash contains handlers for signals. It accepts various values:
If a code-reference is written to it, it will accept use that as handler conjoint with the default $Flags and $Mask.
$Flags
$Mask
If an array-reference is written to is, it will accept that as a tuple of $handler, $flags and $mask. Handler must be a coderef. $flags must be either an integer value (a bitmask of POSIX::SA_* values, or an array-reference containing some of the following entries:
$handler
$flags
$mask
POSIX::SA_*
siginfo
nodefer
restart
onstack
resethand
nocldstop
nocldwait
If an undefined value is written to it, the handler is reset to default.
$Signal::Unsafe::Flags
This contains the default flags. Its initial value is POSIX:SA_SIGINFO
POSIX:SA_SIGINFO
$Signal::Unsafe::Mask
This contains the default mask. Its initial value is an empty mask.
The signal handler will be called as soon as the signal is dispatched to the process/thread, without any userland delay. If the SA_SIGINFO flag is set (which is highly recommended), the handler will not receive one but three argument.
SA_SIGINFO
The signal number
This is simple the number of the signal
The signal information hash
This is a hash containing the following entries:
signo
code
errno
pid
uid
status
utime
stime
int
ptr
overrun
timerid
addr
band
fd
Most values are not meaningful for most signal events.
The signal information as a binary blob
Leon Timmermans <leont@cpan.org>
This software is copyright (c) 2012 by Leon Timmermans.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Signal::Unsafe, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Signal::Unsafe
CPAN shell
perl -MCPAN -e shell install Signal::Unsafe
For more information on module installation, please visit the detailed CPAN module installation guide.