NAME

Linux::Event::Fork::Exit - Value object describing how a child process ended

SYNOPSIS

$loop->fork(
  cmd => [ ... ],
  on_exit => sub ($child, $exit) {
    if ($exit->exited) {
      say "exit code = " . $exit->code;
    } else {
      say "signal    = " . $exit->signal;
    }
  },
);

DESCRIPTION

A Linux::Event::Fork::Exit object describes the termination state of a child process. It is passed to the on_exit callback in the parent process.

It provides a stable, explicit interface over the raw waitpid status.

EXECUTION MODEL

Exit objects are created and observed in the parent process.

The on_exit callback always runs in the parent, inside the Linux::Event event loop.

METHODS

pid

my $pid = $exit->pid;

Process ID of the child that exited.

status

my $status = $exit->status;

The raw wait status integer as returned by waitpid.

exited

if ($exit->exited) { ... }

True if the child exited normally (via exit() or returning from main).

code

my $code = $exit->code;

Exit code (0..255) if exited is true.

Undefined if the child died due to a signal.

signaled

if ($exit->signaled) { ... }

True if the child terminated due to a signal.

signal

my $sig = $exit->signal;

Signal number if signaled is true.

Undefined if the child exited normally.

coredump

if ($exit->coredump) { ... }

True if the child produced a core dump (platform-dependent).

INTERPRETATION GUIDE

Exactly one of these will be true:

  • $exit->exited

    Normal termination; use $exit->code.

  • $exit->signaled

    Signal termination; use $exit->signal (and optionally $exit->coredump).

AUTHOR

Joshua S. Day (HAX)

LICENSE

Same terms as Perl itself.