1IO::Async::Signal(3) User Contributed Perl Documentation IO::Async::Signal(3)
2
3
4
6 "IO::Async::Signal" - event callback on receipt of a POSIX signal
7
9 use IO::Async::Signal;
10
11 use IO::Async::Loop;
12 my $loop = IO::Async::Loop->new();
13
14 my $signal = IO::Async::Signal->new(
15 name => "HUP",
16
17 on_receipt => sub {
18 print "I caught SIGHUP\n";
19 },
20 );
21
22 $loop->add( $signal );
23
24 $loop->loop_forever;
25
27 This module provides a class of "IO::Async::Notifier" which invokes its
28 callback when a particular POSIX signal is received.
29
30 Multiple objects can be added to a "Loop" that all watch for the same
31 signal. The callback functions will all be invoked, in no particular
32 order.
33
34 This object may be used in one of two ways; with a callback function,
35 or as a base class.
36
37 Callbacks
38 If the "on_receipt" key is supplied to the constructor, it should
39 contain a CODE reference to a callback function to be invoked when
40 the signal is received.
41
42 $on_receipt->( $self )
43
44 Base Class
45 If a subclass is built, then it can override the "on_receipt"
46 method.
47
48 $self->on_receipt()
49
51 The following named parameters may be passed to "new" or "configure":
52
53 name => STRING
54 The name of the signal to watch. This should be a bare name
55 like "TERM". Can only be given at construction time.
56
57 on_receipt => CODE
58 CODE reference to callback to invoke when the signal is
59 received. If not supplied, the subclass method will be called
60 instead.
61
62 Once constructed, the "Signal" will need to be added to the "Loop"
63 before it will work.
64
66 Paul Evans <leonerd@leonerd.org.uk>
67
68
69
70perl v5.12.1 2010-06-09 IO::Async::Signal(3)