IO::As...:Signal(3pm)
π 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->run;
π¦ DESCRIPTION π¦
okay so bestie, picture this: IO::Async::Signal is a subclass of IO::Async::Notifier, and what it does is literally fire off its callback the moment a particular POSIX signal shows up. the way it just... catches the vibe check from the kernel π
iconic behaviour fr fr.
and here's the cute part β you can have multiple objects added to a Loop that are all watching for the same signal. every single one of those callbacks is gonna get invoked, and they go in no particular order. so like, don't go assuming who runs first, bestie, because nobody knows πΈ. friendship bracelet energy: everyone gets their turn, order is whatever.
π₯ EVENTS π₯
so these events get invoked either by using subclass methods or CODE references in parameters β your choice, we don't gatekeep π«Ά.
π on_receipt
Invoked when the signal is received. that's it, that's the whole thing. the signal arrives, this goes off π₯.
π PARAMETERS π
these named parameters can be passed to new or configure β pick your entry point, both slay:
β name => STRING
the name of the signal you wanna watch. it should be a bare name like "TERM" β no SIG prefix, no fancy business, just the raw name okay.
β οΈ heads up: this one can only be given at construction time. after that? closed for business, no takebacks, periodt.
π on_receipt => CODE
a CODE reference for the on_receipt event. that's your lil function that runs on receipt, yk?
π«Ά and listen β once you've constructed theSignal, you still need to add it to theLoopbefore it'll work. don't just make it and ghost it, it needs the loop to actually do its thing bestie.
π AUTHOR π
Paul Evans <leonerd@leonerd.org.uk>
and that's a wrap!! this page came to you courtesy of perl v5.40.1, stamped 2026-02-21, from the User Contributed Perl Documentation collection no cap πβ¨ go catch some signals, you got this π
π¦ where this page comes from
- ubuntu stonking: libio-async-perl 0.805-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms