This is the mail archive of the
mailing list for the glibc project.
Re: mmap stdio breaks GNU ld
Paul Eggert <firstname.lastname@example.org> writes:
|> > Date: Tue, 22 Jan 2002 02:13:31 -0600
|> > From: Mark Brown <email@example.com>
|> > Yes, POSIX doesn't make clear that "the position indicated by the
|> > file offset" could be anywhere".
|> That's being generous, as POSIX obscures the issue so much that light
|> barely escapes. For example, here's a quote from the POSIX 1003.1-2001
|> section "Interaction of File Descriptors and Standard I/O Streams":
|> * If any previous active handle has been used by a function that
|> explicitly changed the file offset, except as required above for
|> the first handle, the application shall perform an lseek( ) or
|> fseek( ) (as appropriate to the type of handle) to an appropriate
|> I still can't parse the phrase "except as required above for the first
|> handle", and I've read the context several times.
It refers to the items above the last paragraph, where it states what you
have to do before you can use a file description through a second handle.
There it says, that if you have an input or update stream you need to call
either fflush (if defined at all, I would add) or fclose on it. In other
words, you don't need to call fseek again after fflush, this is the
exception as described in your quote.
Andreas Schwab, SuSE Labs, firstname.lastname@example.org
SuSE GmbH, Deutschherrnstr. 15-19, D-90429 Nürnberg
Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."