NAME
Linux::Perl::signalfd
SYNOPSIS
# One potential way of preventing the signals
# from taking down the process.
Linux::Perl::sigprocmask->block( 'INT', 'ABRT' );
my $sigfd = Linux::Perl::signalfd->new(
flags => ['NONBLOCK', 'CLOEXEC'],
signals => ['INT', 'ABRT'],
);
$sigfd->set_signals( 'INT' );
my @evts = $sigfd->read();
DESCRIPTION
An implementation of Linux’s “signalfd”.
Note that you’ll need to ensure that whatever signals you expect to receive don’t take down the process. sigprocmask can help with this.
METHODS
CLASS->new( %OPTS )
Creates a signalfd instance. %OPTS are:
signals
- An array reference, each of whose members is either a string (e.g.,INT
) or a signal number.flags
- Optional, an array reference of either/both of:NONBLOCK
,CLOEXEC
.
$num = OBJ->fileno()
Returns the file descriptor, which can be used with, e.g., select()
, epoll(), or poll()
.
@signals = OBJ-read()
Reads events from the signalfd instance. Each event is a hash reference whose keys and values correspond to struct inotify_event
. (cf. man 7 inotify
)
In scalar context the return is the number of hash references that would be returned in list context.
An empty return (0 in scalar context) is an error state, in which case $!
will indicate what the error was.
OBJ->set_signals( @SIGNALS )
Updates the signalfd instance’s list of signals to listen for. @SIGNALS is a list such as the constructor’s signals
argument.
This returns the instance.
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 27:
Non-ASCII character seen before =encoding in 'Linux’s'. Assuming UTF-8