NAME

Linux::Event::Pid - pidfd-backed process-exit subscriptions for Linux::Event::Loop

SYNOPSIS

use v5.36;
use Linux::Event;

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

my $pid = fork() // die "fork: $!";
if ($pid == 0) { exit 42 }

my $sub = $loop->pid($pid, sub ($loop, $pid, $status, $data) {
  ...
});

DESCRIPTION

Linux::Event::Pid adapts Linux pidfds into the readiness loop. It opens a pidfd using Linux::FD::Pid, watches it like any other readable filehandle, and invokes the callback when the target process exits.

Most users access it through $loop->pid(...).

CALLBACK ABI

Pid callbacks receive four arguments:

$cb->($loop, $pid, $status, $data)

When reap => 1 is in effect and the target is a child process, $status is the wait status value. Otherwise it may be undef.

OPTIONS

Recognized subscription options:

  • data

  • reap

SUBSCRIPTIONS

The returned subscription object supports cancel.

SEE ALSO

Linux::Event::Loop, Linux::FD::Pid