NAME
WiringPi::API::BackgroundInterrupt - Handle for a single-pin background interrupt child
SYNOPSIS
use WiringPi::API qw(setup pin_mode background_interrupt INT_EDGE_RISING);
setup();
pin_mode(17, 0);
my $h = background_interrupt(17, INT_EDGE_RISING, \&on_edge);
# ... main does its own work ...
$h->stop; # idempotent; END reaps if forgotten
DESCRIPTION
An object of this class is returned by "background_interrupt($pin, $edge, $callback, $debounce_us)" in WiringPi::API. It owns one forked child that arms the interrupt and runs the callback on each edge.
You never construct one directly - background_interrupt() forks the child and hands you the handle.
It is also the lifecycle base class for the other background-handle classes: WiringPi::API::BackgroundInterrupts (shared multi-pin child), WiringPi::API::Worker (fork-based worker) and, transitively, WiringPi::API::WorkerThread. The pid/running/stop/DESTROY fork lifecycle (TERM -> poll -> KILL -> reap) is mechanism-agnostic, so those subclasses inherit it wholesale.
METHODS
pid
The forked child's process id.
running
True while the child is still alive; false once it has stopped. Reaps the child without blocking (via waitpid WNOHANG) so the result reflects reality.
stop
Stop the child and reap it: send TERM, poll briefly for a clean exit, then escalate to KILL. Idempotent - safe to call more than once, and DESTROY reaps the child if you forget. Returns 1.
read
Non-blocking drain of the results channel (when the child was started with results => 1): returns the next value the handler reported, or undef if none is ready or the channel is closed/disabled.
fh
The results read handle, suitable for select/IO::Select, or undef when the results channel is not enabled.
SEE ALSO
WiringPi::API, WiringPi::API::BackgroundInterrupts, WiringPi::API::Worker, WiringPi::API::WorkerThread.
AUTHOR
Steve Bertrand, <steveb@cpan.org>
COPYRIGHT AND LICENSE
Copyright (C) 2017-2026 by Steve Bertrand
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.18.2 or, at your option, any later version of Perl 5 you may have available.