MooseX::Types::Signal - a type to represent valid UNIX or Perl signals
version 1.101932
Often times you want to send a configurable signal, but you don't want someone specifying SIGLOLCAT or 1234, because those aren't valid signals. Or are they?
With this module, you don't have to know; it will figure out what is valid and what isn't, and what names map to what numbers.
Just use the Signal type, and signal numbers are validated. Use the coercion, and you can refer to signals by name, too.
Signal
package Example; use MooseX::Types::Signal qw(Signal); use Moose; has 'kill_with' => ( is => 'rw', isa => Signal, coerce => 1, ); my $example = Example->new; # kill with SIGKILL $example->kill_with(9); $example->kill_with('KILL'); $example->kill_with('SIGKILL'); # in any case, the reader C<kill_with> will always return 9, or # whatever your system thinks the number for SIGKILL is
MooseX::Types::Signal exports a type, Signal, that recognizes valid signals on your platform. The underlying type is a non-negative number, but there is a coercion from strings to numbers that recognizes signals by name.
MooseX::Types::Signal
There are also more restrictive types, PerlSignal and UnixSignal. UnixSignal only understands signals that are in your system's signal.h header file. PerlSignal only understands signals that are in Perl's %Config hash. Signal is either/or, with preference to UnixSignal over PerlSignal when coercing.
PerlSignal
UnixSignal
signal.h
%Config
The exports Signal, UnixSignal, and PerlSignal are exported by Sub::Exporter, so you must explicitly request them, and you can use any of Sub::Exporter's magic when doing so. This is true in general of MooseX::Types modules.
MooseX::Types
Jonathan Rockway <jrockway@cpan.org>
This software is copyright (c) 2011 by Jonathan Rockway.
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 MooseX::Types::Signal, copy and paste the appropriate command in to your terminal.
cpanm
cpanm MooseX::Types::Signal
CPAN shell
perl -MCPAN -e shell install MooseX::Types::Signal
For more information on module installation, please visit the detailed CPAN module installation guide.