in reply to EINTR and sysread()

To answer your other question about getting the child status, you shouldn't have to install a CHLD signal handler to do that. Perl will keep track of the child's exit status when you fork and create a pipe using open and will set $? when you close the pipe.

In fact, if you install a signal handler for SIGCHLD, perl won't keep track of the exit status for you, so I would use such a signal handler only if there are other compelling reasons to do so. In that case you'll have to do something like this:

our $pid; # remember the child's pid our $status; sub handle_sigchld { my $wpid = waitpid -1, WNOHANG; # use POSIX for WNOHANG if ($wpid == $pid) { $status = $?; } } ... $pid = open(INPIPE, "...|");

Replies are listed 'Best First'.
Re^2: EINTR and sysread()
by bot403 (Beadle) on Apr 05, 2008 at 00:33 UTC

    In the course of my debugging I was getting a 'No child process' error so I assumed perl was reaping it automatically and discarding the return. I was probably just doing something else wrong.

    I did implement all of your suggestions and it works much better now.

    Thanks!