The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

IO::Async::Signal - event callback on receipt of a POSIX signal

SYNOPSIS

 use IO::Async::Signal;

 use IO::Async::Loop;
 my $loop = IO::Async::Loop->new();

 my $signal = IO::Async::Signal->new(
    name => "HUP",

    on_receipt => sub {
        print "I caught SIGHUP\n";
    },
 );

 $loop->add( $signal );

 $loop->loop_forever;

DESCRIPTION

This subclass of IO::Async::Notifier invokes its callback when a particular POSIX signal is received.

Multiple objects can be added to a Loop that all watch for the same signal. The callback functions will all be invoked, in no particular order.

This object may be used in one of two ways; as an instance with CODE references as callbacks, or as a base class with overridden methods.

Subclassing

If a subclass is built, then it can override the following methods to handle events:

 $self->on_receipt()

PARAMETERS

The following named parameters may be passed to new or configure:

name => STRING

The name of the signal to watch. This should be a bare name like TERM. Can only be given at construction time.

on_receipt => CODE

CODE reference to callback to invoke when the signal is received. If not supplied, the subclass method will be called instead.

 $on_receipt->( $self )

Once constructed, the Signal will need to be added to the Loop before it will work.

AUTHOR

Paul Evans <leonerd@leonerd.org.uk>