NAME

WiringPi::API::BackgroundInterrupts - Handle for a shared multi-pin background interrupt child

SYNOPSIS

use WiringPi::API qw(setup pin_mode background_interrupts INT_EDGE_RISING
                     INT_EDGE_BOTH);

setup();
pin_mode(17, 0);
pin_mode(27, 0);

my $h = background_interrupts(
    [17, INT_EDGE_RISING, \&on_button],
    [27, INT_EDGE_BOTH,   \&on_sensor, 5000],
);

$h->disarm(27);   # stop servicing pin 27 (without killing the child)
$h->arm(27);      # resume it
$h->stop;         # tear down + reap the one child

DESCRIPTION

An object of this class is returned by "background_interrupts([$pin, $edge, $callback, $debounce_us], ...)" in WiringPi::API. A single forked child services many pins from one dispatch loop, and this handle drives it.

You never construct one directly - background_interrupts() forks the child and hands you the handle.

It is a subclass of WiringPi::API::BackgroundInterrupt and inherits that class's pid, running and DESTROY lifecycle. A shared child has no per-pin results channel (that is the singular background_interrupt({results => 1}) contract), so the inherited read/fh are overridden to croak rather than silently return undef.

METHODS

arm($pin)

Resume servicing $pin, which must be one of the pins registered in the original background_interrupts() call. Croaks otherwise. Returns 0 if the child is no longer running, 1 once the arm command is sent.

disarm($pin)

Stop servicing $pin (without killing the child), which must be one of the pins registered in the original call. Croaks otherwise. Returns 0 if the child is no longer running, 1 once the disarm command is sent.

stop

Close the control pipe (giving the child an EOF shutdown path), then stop and reap the child via the inherited stop. Idempotent. Returns 1.

fh / read

The shared child has no results channel, so both of these croak. Use a per-pin "background_interrupt($pin, $edge, $callback, $debounce_us)" in WiringPi::API with { results => 1 } when you need values back from a handler.

SEE ALSO

WiringPi::API, WiringPi::API::BackgroundInterrupt.

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.