Eric Blake wrote: > > You said that you got an fflush failure on mingw. Could you please > > show a test program that failed before? > > The m4 test suite detected failures on mingw due to this code that got > invoked prior to the syscmd macro, in an attempt to follow the POSIX rule > that for seekable streams, child processes should see the stream at the > next character left unprocessed by the parent: > > if (lseek (STDIN_FILENO, 0, SEEK_CUR) >= 0 > && fflush (stdin) == 0) > { > fseeko (stdin, 0, SEEK_CUR); > } > > The failures in the m4 testsuite were due to lost data since the fflush > discarded what was on the pipe, even though the fflush should never have > been reached.
Thanks for explaining. I thought you were talking about the lseek call inside fflush, not about an lseek call before it. Since loss of data is a severe condition, I'm adding a note about it: 2007-05-28 Bruno Haible <[EMAIL PROTECTED]> * lib/stdio_.h (fflush): More comments. --- lib/stdio_.h 24 May 2007 16:59:21 -0000 1.27 +++ lib/stdio_.h 28 May 2007 13:52:52 -0000 @@ -270,7 +270,11 @@ # if @REPLACE_FFLUSH@ # define fflush rpl_fflush /* Flush all pending data on STREAM according to POSIX rules. Both - output and seekable input streams are supported. */ + output and seekable input streams are supported. + Note! LOSS OF DATA can occur if fflush is applied on an input stream + that is _not_seekable_ or on an update stream that is _not_seekable_ + and in which the most recent operation was input. Seekability can + be tested with lseek(fileno(fp),0,SEEK_CUR). */ extern int fflush (FILE *gl_stream); # endif #elif defined GNULIB_POSIXCHECK