in reply to Re: fork() interferring with backtick
in thread fork() interferring with backtick

Actually I do have a SIG{CHLD} handler. It occurs before the code block:
my $queue = []; sub REAP { my $kidpid; while(($kidpid = waitpid(-1,WNOHANG)) > 0) { #p rint "reaped $kidpid\n"; push @$queue, [ $kidpid, $? ]; } } $SIG{'CHLD'} = \&REAP;
i didn't include it earlier thinking it didn't matter

Replies are listed 'Best First'.
Re^3: fork() interferring with backtick
by vsespb (Chaplain) on Oct 16, 2013 at 19:14 UTC
    REAP called for external programs called with backtricks, however it seems it does not affect anything in your case.
    my $queue = []; sub REAP { my $kidpid; print STDERR "HANDLER\n"; while(($kidpid = waitpid(-1,WNOHANG)) > 0) { print STDERR "reaped $kidpid\n"; push @$queue, [ $kidpid, $? ]; } print STDERR "/HANDLER\n"; } $SIG{'CHLD'} = \&REAP; `echo 1`; my $pid = fork(); print STDERR "FORK CHILD $pid\n" if $pid; exit unless ($pid); print STDERR "before sleep\n"; sleep 2; print STDERR "after sleep\n"; print STDERR "DONE\n"; __END__ HANDLER /HANDLER FORK CHILD 29104 before sleep HANDLER reaped 29104 /HANDLER after sleep DONE
      I think my problem has to do with http://www.perlmonks.org/?node_id=1026468 I'm running 5.14 - my system hasn't been upgraded yet