From: Mark-Jason Dominus Date: Wed, 11 Aug 1999 15:56:09 +0000 (-0400) Subject: Flush buffer before duplicating file descriptor. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=54195c32bb1734df4d96f8aca2d65e155aa0b341;p=p5sagit%2Fp5-mst-13.2.git Flush buffer before duplicating file descriptor. To: Graham Barr cc: Vicki Brown , perl5-porters@perl.org, mjd@plover.com Subject: Re: [ID 19990811.002] can't dup DATA? (PATCH (5.005_57)) Date: Wed, 11 Aug 1999 15:56:09 -0400 Message-ID: <19990811195610.5933.qmail@plover.com> From: Mark-Jason Dominus To: perl5-porters@perl.org Subject: Re: [ID 19990811.002] can't dup DATA? (PATCH (5.005_57)) Date: Wed, 11 Aug 1999 16:05:46 -0400 Message-ID: <19990811200546.6165.qmail@plover.com> p4raw-id: //depot/cfgperl@3960 --- diff --git a/doio.c b/doio.c index cc34733..a953d54 100644 --- a/doio.c +++ b/doio.c @@ -282,7 +282,10 @@ Perl_do_open9(pTHX_ GV *gv, register char *name, I32 len, int as_raw, goto say_false; } if (IoIFP(thatio)) { - fd = PerlIO_fileno(IoIFP(thatio)); + PerlIO *fp = IoIFP(thatio); + /* Flush stdio buffer before dup */ + PerlIO_seek(fp, 0, SEEK_CUR); + fd = PerlIO_fileno(fp); if (IoTYPE(thatio) == 's') IoTYPE(io) = 's'; } diff --git a/pod/perldelta.pod b/pod/perldelta.pod index 029d315..28a786e 100644 --- a/pod/perldelta.pod +++ b/pod/perldelta.pod @@ -301,6 +301,14 @@ are compile time errors. Attempting to read from filehandles that were opened only for writing will now produce warnings (just as writing to read-only filehandles does). +=head2 Buffered data discarded from input filehandle when dup'ed. + +C&OLD")> now discards any data that was previously +read and buffered in C. The next read operation on C will +return the same data as the corresponding operation on C. +Formerly, it would have returned the data from the start of the +following disk block instead. + =head1 Supported Platforms =over 4