develooper Front page | perl.perl5.porters | Postings from September 1999

Re: perl5.005_61 io/dup test 7 legal?

Thread Previous
Gurusamy Sarathy
September 20, 1999 09:08
Re: perl5.005_61 io/dup test 7 legal?
Message ID:
On Thu, 26 Aug 1999 10:58:07 MDT, "Todd C. Miller" wrote:
>test 7 in t/io/ from perl5.005_61 would seem to fly in the
>face of the following from perlfunc:
>    Duping a filehandle does not take into account any existing
>    contents of stdio buffers.
>And it does fail on 4.4BSD-derived stdio's.  A syscall trace shows that
>the first read is actually reading both lines so when the dup'd fd
>is read from, there's nothing left.
>This doesn't seem like a bug in the 4.4BSD stdio to me.  When opening
>the file with "+<" the test succeeds.  This may be due to the fact that
>stdio has optimizations for seeking on files that are _not_ read-write.
>This seems to avoid some of the buffering.
>Anyone care to comment?

The test has been removed because there appears to be no way to make
the behavior completely portable.

Perl will still attempt to seek-and-flush before duping a handle,
but whether your stdio will cooperate or not is unspecified.

It is a crying shame that ANSI did not specify a way to force the
"flushing" of input handles to avoid buffering headaches.  Does
anyone know if C9X does anything about this?


Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About