Signal::Pipe - Self pipes for signal handling
version 0.001
use POSIX 'SIGINT'; use Signal::Pipe 'selfpipe'; my $fh = selfpipe(SIGINT); add_handler($fh, sub { if (sysread($fh, my $buf, 128)) { # handle signal } });
This function sets a signal handler $signo for the process that will write one byte for each handled signal to the file handle that is returned by this function. When the handle becomes readable, you want to drain the filehandle using sysread. The handle is automatically made non-blocking, and signals may be squashed.
$signo
Note that there may only be one such handle for each signal in the process, and that the signal delivery is mostly shared between different threads in the same process.
Async::Interrupt
A module that can do a similar thing (and some other things).
Linux::FD::Signal
A linux specific module that allows one to pass much more information.
Leon Timmermans <leont@cpan.org>
This software is copyright (c) 2015 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::Pipe, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Signal::Pipe
CPAN shell
perl -MCPAN -e shell install Signal::Pipe
For more information on module installation, please visit the detailed CPAN module installation guide.