in reply to Weird open() return code in pipe mode
It must act like system, where the shell (/bin/sh) is only involved if necessary.
It's not involved for open PIPE, "pfrrzt |" since the command contain no special shell characters. Perl is not able to launch pfrrzt, so open returns an error.
On the other hand, open PIPE, "pfrrzt >/dev/null |" does involve special shell characters (>), so /bin/sh is loaded to execute the command. Perl is able to successfully execute /bin/sh, so open returns the child's (the shell's) pid.
I think you can check if the pipe is open using eof. If it's not open, you can close the pipe and then get the child's error code via $?.
|
|---|