This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: mmap stdio breaks GNU ld


> From: Andreas Schwab <schwab@suse.de>
> Date: Tue, 22 Jan 2002 11:38:08 +0100

> |> 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.

Sorry, I still don't understand it, even with your explanation.  The
items above the last paragraph (let's call them the "IOTLP") talk
about what you have to do handle 1 first, before you can switch to
handle 2.  Basically you have to either close 1 or fflush 1, but there
are some exceptions where you don't need to close or fflush 1.  (The
IOTLP don't mention fseek.)

So a natural interpretation of "except as required above for the first
handle" would refer to those exceptions.  But this interpretation
can't be correct.  For example, here's one of the IOTLP:

  * If the stream is open for reading and it is at the end of the file
    (feof( ) is true), no action need be taken.

Under the natural interpretation that I mentioned, if handle 1 is an
input stream at EOF, then you can just fread 2 without doing anything
special.  But this doesn't make sense, since handle 2 might be a
buffered stream and you might need to fseek 2 to bring 2 back into
sync with its underlying file descriptor.

I must be missing something here.  (The only thing that is
clear to me is that the POSIX spec is unclear.  :-)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]