in reply to Re^8: open3 and illegal seeks
in thread open3 and illegal seeks
Since I'm now only reading from $PROG_STDERR when there's data to be read (!eof), reading nothing does indicate an error, right?
It it was a file... But we're talking about a pipe. It might not be closed when you check eof, but it could close after you started trying to read from it.
Or so I thought.
eof apparently does a read to find out if more data is coming.
$ perl -wle' open(my $fh, "-|", sleep => 5) or die $!; print eof($fh)?1:0; print defined(scalar(<$fh>))?1:0; print eof($fh)?1:0 ' <<eof blocks for 5 seconds here>> 1 0 1
This behaviour is very different than the behaviour of stdio's feof, but it's documented: eof "Returns 1 if the next read on FILEHANDLE will return end of file, or if FILEHANDLE is not open."
So, you're right. Reading nothing in that situation would indicate a reading error (and thus, you can print out $!).
(No consideration was given to non-blocking handles.)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^10: open3 and illegal seeks
by ig (Vicar) on Jul 10, 2009 at 03:59 UTC |