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.)


In reply to Re^9: open3 and illegal seeks by ikegami
in thread open3 and illegal seeks by brainsick

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.