in reply to Re: open with pipe
in thread open with pipe

Use close (implicitly or explicitly) with open, not waitpid.
$ perl -E' open(my $pipe, "-|", "perl -e'\''sleep 5; exit 3'\''"); say time; close($pipe); say time; say $?>>8; ' 1280645564 1280645569 3

Replies are listed 'Best First'.
Re^3: open with pipe
by repellent (Priest) on Aug 01, 2010 at 17:47 UTC
    Sure, close can wait for "-|". But why not waitpid?
    $ perl -E' $pid = open(my $pipe, "-|", "perl -e'\''sleep 5; exit 3'\''"); say time; waitpid($pid, 0); say time; say $?>>8; ' 1280685258 1280685263 3

    waitpid is documented with:

      Waits for a particular child process to terminate and returns the pid of the deceased process, or -1 if there is no such child process.

      The status is returned in $? and ${^CHILD_ERROR_NATIVE}.

      Calling waitpid twice for the same process doesn't seem right to me.