NAME
Signal::Unsafe - Unsafe signal handlers made convenient
VERSION
version 0.006
SYNOPSIS
$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;
DESCRIPTION
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.
VARIABLES
%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
.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 ofPOSIX::SA_*
values, or an array-reference containing some of the following entries: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
$Signal::Unsafe::Mask
This contains the default mask. Its initial value is an empty mask.
SIGNAL HANDLER
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.
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
AUTHOR
Leon Timmermans <leont@cpan.org>
COPYRIGHT AND LICENSE
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.