[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: seekable stdin test failure on OS X

From: Ben Pfaff
Subject: Re: seekable stdin test failure on OS X
Date: Mon, 02 Apr 2007 11:56:54 -0700
User-agent: Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux)

Paul Eggert <address@hidden> writes:

> Ben Pfaff <address@hidden> writes:
>> ISO C89 and C99 say that fflush(stdin) yields undefined behavior,
>> so I'm inclined to agree.
> Here's how I remember it; I haven't checked the actual documents.  In
> the late 1980s the POSIX committee decided that fflush (stdin) should
> flush the input buffer and (on seekable devices) restore the input
> position on the underyling file descriptor to match the position in
> the stream.  At some point in the mid-1990s this requirement was
> weakened to be more like (but not exactly like) ISO C89.  However, in
> the latest POSIX it's stronger again, and is more like the late 1980s.

Is there a version of POSIX newer than "The Open Group Base
Specifications Issue 6: IEEE Std 1003.1, 2004 Edition"?  This
version doesn't say anything about the behavior of fflush for
input streams, or at least it doesn't on the page dedicated to

> Anyway, for what it's worth I think fflush (stdin) should behave like
> 1988 POSIX and glibc, at least for apps that care about this sort of
> thing.

If apps want that behavior then it entirely makes sense to
implement it (and I really shouldn't have stuck my oar in).

I'm surprised that glibc implements this behavior for fflush on
input streams: the glibc manual I have here doesn't mention it.
But I can see in the libio sources that glibc does do it.
Ben Pfaff

reply via email to

[Prev in Thread] Current Thread [Next in Thread]