in reply to $? outside SIGCHLD handler

ug, use IO::Select. It's a thin wrapper over select that's *much* easier to use than the underlying function.

You didn't show your signal handler. If it calls wait or waitpid, don't call wait or waitpid outside of the handler. Save the result from the handler, if you need to.

my %reaped; $SIG{CHLD} = sub { my $pid = wait(); $reaped{$pid} = $?; }; # When reading from read ready handle returns eof, my $exit_code = delete $reaped{$pid_associated_with_handle};

Replies are listed 'Best First'.
Re^2: $? outside SIGCHLD handler
by Anonymous Monk on Sep 08, 2009 at 18:24 UTC
    Hello.

    Sorry for long delay, I had no access to internet during weekend.

    I'll probably switch to IO::Select later, select() code works fine so far.

    Code for CHLD handler is after "CHLD handler does just this ..." in my original post (No wait()/waitpid() calls inside).

    I was just confused by sentence from "perlvar" (see end of orig post).

      I forgot to log in. The reply above is mine.