NAME

Linux::Event::Signal - signalfd integration for Linux::Event

SYNOPSIS

use v5.36;
use Linux::Event;

my $loop = Linux::Event->new;

my $sub = $loop->signal('INT', sub ($loop, $sig, $count, $data) {
  $loop->stop;
});

$loop->run;

DESCRIPTION

This module provides Linux signalfd integration for Linux::Event::Loop. The loop exposes this via $loop->signal(...), but all implementation details live here to keep Loop.pm small.

The semantics for this feature are frozen by the project's M2.1 signals contract:

  • One signalfd per loop (created lazily on first registration)

  • Single or multiple signals accepted at registration time

  • One handler per signal; subsequent registration replaces

  • Callback signature (strict): ($loop, $sig, $count, $data)

  • No fan-out policy; users can implement fan-out themselves

  • Returned subscription handle supports idempotent cancel

METHODS

new(loop => $loop)

Create a signal adaptor bound to the given loop.

signal($sig_or_list, $cb, %opt) -> $subscription

Register one (or many) signals and associate them with a callback.

$sig_or_list may be:

  • a signal number

  • a signal name ('INT') or with prefix ('SIGINT')

  • an arrayref of the above

Options:

  • data - arbitrary user value passed as the final callback argument

Returns a subscription handle object with a cancel method.

SEE ALSO

Linux::Event::Loop, Linux::FD, signalfd(2)

VERSION

This document describes Linux::Event::Signal version 0.006.

AUTHOR

Joshua S. Day

LICENSE

Same terms as Perl itself.