require POSIX;
require Time::HiRes;
+ my @pids;
+ $SIG{CHLD} = sub {
+ while ((my $child = waitpid(-1, POSIX::WNOHANG())) > 0) {
+ note "Reaped: $child";
+ push @pids, $child;
+ }
+ };
my $pid = fork // die "Can't fork: $!";
unless ($pid) {
note("Child PID: $$");
test_system('without reaper');
- my @pids;
- $SIG{CHLD} = sub {
- while ((my $child = waitpid(-1, POSIX::WNOHANG())) > 0) {
- note "Reaped: $child";
- push @pids, $child;
- }
- };
-
test_system('with reaper');
note("Waiting briefly for SIGCHLD...");