From: Jarkko Hietaniemi <jhi@iki.fi>
Date: Fri, 17 Sep 1999 20:08:00 +0000 (+0000)
Subject: The change #4176 should've undone only the test, not the code patch.
X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=7211d486c2f1b50ce739944f532a265536a2f0f5;p=p5sagit%2Fp5-mst-13.2.git

The change #4176 should've undone only the test, not the code patch.

p4raw-link: @4176 on //depot/cfgperl: b7a02c4fb533bb0a7ae92f82a4a660045d95669a

p4raw-id: //depot/cfgperl@4179
---

diff --git a/doio.c b/doio.c
index 793b540..0b1cdd1 100644
--- 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';