MooseX::Types::Signal - a type to represent valid UNIX or Perl signals
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
and signal numbers are validated.
Use the coercion,
and you can refer to signals by name,
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.
There are also more restrictive types,
UnixSignal only understands signals that are in your system's
signal.h header file.
PerlSignal only understands signals that are in Perl's
Signal is either/or, with preference to
PerlSignal when coercing.
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
Jonathan Rockway <email@example.com>
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.