This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
A fix of sorts for the flush-before-dup scenario.
authorJarkko Hietaniemi <jhi@iki.fi>
Mon, 16 Aug 1999 19:20:37 +0000 (19:20 +0000)
committerJarkko Hietaniemi <jhi@iki.fi>
Mon, 16 Aug 1999 19:20:37 +0000 (19:20 +0000)
p4raw-id: //depot/cfgperl@3997

doio.c

diff --git a/doio.c b/doio.c
index 8610a14..413e342 100644 (file)
--- a/doio.c
+++ b/doio.c
@@ -283,8 +283,17 @@ Perl_do_open9(pTHX_ GV *gv, register char *name, I32 len, int as_raw,
                        }
                        if (IoIFP(thatio)) {
                            PerlIO *fp = IoIFP(thatio);
-                               /* Flush stdio buffer before dup */
+                           /* Flush stdio buffer before dup. --mjd
+                            * Unfortunately SEEK_CURing 0 seems to
+                            * be optimized away on most platforms;
+                            * only Solaris and Linux seem to flush
+                            * on that. --jhi */
                            PerlIO_seek(fp, 0, SEEK_CUR);
+                           /* On the other hand, do all platforms
+                            * take gracefully to flushing a read-only
+                            * filehandle?  Perhaps we should do
+                            * fsetpos(src)+fgetpos(dst)?  --nik */
+                           PerlIO_flush(fp);
                            fd = PerlIO_fileno(fp);
                            if (IoTYPE(thatio) == 's')
                                IoTYPE(io) = 's';