EV::Child#
A child process watcher, as EV::child makes: its callback runs when a child ends (or, traced, stops or continues). These methods give the child’s pid and status; the methods all watchers share are EV::Watcher’s. Only the default loop watches children.
EV reaps the children it reports: their status is rstatus, not $? from a waitpid of your own.
Synopsis#
my $pid = fork // die "fork: $!";
exec 'sleep', 1 unless $pid;
my $w = EV::child $pid, 0, sub {
my ($w) = @_;
printf "%d exited with %d\n", $w->rpid, $w->rstatus >> 8;
};
EV::run;
Functions#
Status#
reinit#
Re-install EV’s own SIGCHLD handler: EV::Child::reinit, after code such as local $SIG{CHLD} left another one behind and child watchers stopped firing. Experimental upstream; its form may change.
set#
Watch another child: $w->set($pid, $trace), as EV::child takes them - $pid 0 for any child.
pid#
The pid the watcher watches (0 for any child). The same method gives, under its other names, what the last status change reported: $w->rpid, the pid of the child that changed - useful when watching any child - and $w->rstatus, its wait status as waitpid sets $? (>> 8 for the exit code).
Also available as EV::Child::rpid, EV::Child::rstatus.