saintmike has asked for the wisdom of the Perl Monks concerning the following question:
This will correctly print an error message and die() afterwards:open PIPE, "pfrrzt |" or die "failed!";
But if the command redirects its standard output to /dev/null, open will return a true value instead:Can't exec "pfrrzt": No such file or directory at ./test line 9. failed! at ./t line 9.
which doesn't trigger the die() statement.open PIPE, "pfrrzt >/dev/null |" or die "failed!";
Interestingly, the popen() function used internally won't catch a non-existing program name and return an OK pointer to a FILE struct either way.
What's the magic at the Perl level that causes the behavior mentioned above? ~
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Weird open() return code in pipe mode
by ikegami (Patriarch) on Sep 21, 2007 at 04:13 UTC | |
|
Re: Weird open() return code in pipe mode
by duff (Parson) on Sep 21, 2007 at 04:08 UTC | |
|
Re: Weird open() return code in pipe mode
by graff (Chancellor) on Sep 22, 2007 at 01:52 UTC |