in reply to External program called via system does not come back

Just to report back what I come up with (ideas stolen from Perl Cookbook and the Perl command reference)
use strict; use warnings; use IPC::Run; use POSIX qw(:signal_h :errno_h :sys_wait_h); use Config; ... my $has_nonblocking = $Config{d_waitpid} eq "define" || $Config{d_wait +4} eq "define"; if ($has_nonblocking) { $SIG{CHLD} = \&REAPER; sub REAPER { my $pid = waitpid(-1, &WNOHANG); # wait for any child, return PID +if state changed else return 0 if stopped or -1 if error if ($pid == -1) { # ignore } elsif ( &WIFEXITED($?) ) { # true if exited normally print "$pid exited.\n"; } else { # must have been some stop signal or no change in state print "False alarm $pid.\n"; } $SIG{CHLD} = \&REAPER; } my $pid = fork(); defined $pid or die $!; unless ($pid) { my @args = ( ... ); run \@args or die $?; exit; } my $kid; do { $kid = waitpid(-1, &WNOHANG); } while $kid > 0; } ... exit;
Please comment and give advice. Thank you.