Linux::Perl::signalfd
# 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();
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.
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.
signals
INT
flags - Optional, an array reference of either/both of: NONBLOCK, CLOEXEC.
flags
NONBLOCK
CLOEXEC
Returns the file descriptor, which can be used with, e.g., select(), epoll(), or poll().
select()
poll()
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)
struct inotify_event
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.
$!
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:
Non-ASCII character seen before =encoding in 'Linux’s'. Assuming UTF-8
To install Linux::Perl, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Linux::Perl
CPAN shell
perl -MCPAN -e shell install Linux::Perl
For more information on module installation, please visit the detailed CPAN module installation guide.