Reflex::Role::SigCatcher - add signal catching behavior to a class
This document describes version 0.100, released on April 02, 2017.
package Reflex::Signal; use Moose; extends 'Reflex::Base'; has signal => ( is => 'ro', isa => 'Str', required => 1, ); has active => ( is => 'ro', isa => 'Bool', default => 1, ); TODO - Changed. with 'Reflex::Role::SigCatcher' => { signal => 'signal', active => 'active', cb_signal => 'on_signal', method_start => 'start', method_stop => 'stop', method_pause => 'pause', method_resume => 'resume', }; 1;
Reflex::Role::SigCatcher is a Moose parameterized role that adds signal-catching behavior to Reflex based classes. The SYNOPSIS is the entire implementation of Reflex::SigCatcher, a simple class that allows Reflex::Role::SigCatcher to be used as an object.
Reflex::Role::SigCatcher is not suitable for SIGCHLD use. The specialized Reflex::Role::PidCatcher class is used for that, and it will automatically wait() for processes and return their exit statuses.
None. All role parameters as of this writing have what we hope are sensible defaults. Please let us know if they don't seem all that sensible.
signal sets the name of an attribute that will contain the signal name to catch. Signal names are as those found in %SIG.
signal
TODO - However, it may also be convenient to specify the signal name in the role's parameters. General use cases don't usually require signals names to change. The indirection through signal is currently useful for Reflex::Signal, however, so we probably need both modes. It might be better to provide two roles, one for each behavior, rather than one role that does both.
active specifies whether Reflex::Role::SigCatcher should be created in the active, signal-watching state. All Reflex watchers are enabled by default. Set it to a false value, preferably 0, to initialize the catcher in an inactive or paused mode.
active
Signal watchers may be paused and resumed. See method_pause and method_resume for ways to override the default method names.
method_pause
method_resume
cb_signal names the $self method that will be called whenever the signal named in <$self-$signal()>> is caught. It defaults to "on_%s_caught", where %s is the name of the signal. So if the INT signal is being watched, cb_signal will default to "on_INT_caught".
cb_signal
<$self-
method_start sets the name of the method that may be used to initially start catching signals. It's "start_%s" by default, where %s is the signal name being caught.
method_start
Reflex::Role::SigCatcher will automatically start watching for signals if the value of active's attribute is true.
method_stop may be used to permanently stop signal catchers. Stopped catchers cannot be restarted, so use method_pause if you need to temporarily disable signal watchers. method_resume may be used to resume them again.
method_stop
Signal catchers will automatically stop watching for signals upon DEMOLISH.
method_pause sets the name of the method that may be used to pause signal catching. It is "pause_%s" by default, where %s is the signal name being caught.
method_resume sets the name of the method that may be used to resume signal catching. It is "resume_%s" by default, where %s is the signal name being caught.
eg/eg-39-signals.pl shows how Reflex::Signal may be used with callbacks or promises.
Reflex::Signal is a simple class that watches for signals with Reflex::Role::SigCatcher.
Please see those modules/websites for more information related to this module.
Reflex
Reflex::Signal
Reflex::Role::PidCatcher
Reflex::PID
"ACKNOWLEDGEMENTS" in Reflex
"ASSISTANCE" in Reflex
"AUTHORS" in Reflex
"BUGS" in Reflex
"CONTRIBUTORS" in Reflex
"COPYRIGHT" in Reflex
"LICENSE" in Reflex
"TODO" in Reflex
You can make new bug reports, and view existing ones, through the web interface at http://rt.cpan.org/Public/Dist/Display.html?Name=Reflex.
Rocco Caputo <rcaputo@cpan.org>
This software is copyright (c) 2017 by Rocco Caputo.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
The latest version of this module is available from the Comprehensive Perl Archive Network (CPAN). Visit http://www.perl.com/CPAN/ to find a CPAN site near you, or see https://metacpan.org/module/Reflex/.
BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
To install Reflex, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Reflex
CPAN shell
perl -MCPAN -e shell install Reflex
For more information on module installation, please visit the detailed CPAN module installation guide.