C99 freopen
Roland McGrath
roland@frob.com
Mon Apr 9 14:10:00 GMT 2001
That is not a reasonable approach. I don't have the C99 spec so as to read
what its intent is supposed to be--but I find it hard to believe they
intended POSIX systems to introduce the one place where you can expect to
have the effect of determining a file name from a file descriptor (which in
the general case cannot be done). The only thing that seems reasonable to
me is that this is expected only to work in the common case where
stdin/stdout/stderr are all copied from the same original descriptor on the
tty, that having been opened O_RDWR. So, freopen's semantics would roughly
match those of fdopen(fileno(stream), newmode)--which is to say that
freopen can do the fcntl(F_GETFL) check on the requested new mode and tweak
the stream state to match the requested new mode, but that is all.
More information about the Libc-hacker
mailing list