diff options
author | Eric Blake <eblake@redhat.com> | 2007-07-31 20:49:40 +0000 |
---|---|---|
committer | Eric Blake <eblake@redhat.com> | 2007-07-31 20:49:40 +0000 |
commit | f7c978d50fb7f510864ff4770fa7793a47a0b613 (patch) | |
tree | 20d5a4f5ee4a84376a8d70a8567e1e875a896f2c /newlib/libc/stdio/fdopen.c | |
parent | 8b5fa210a6acedf46114485082d52a23cbc635ee (diff) | |
download | cygnal-f7c978d50fb7f510864ff4770fa7793a47a0b613.tar.gz cygnal-f7c978d50fb7f510864ff4770fa7793a47a0b613.tar.bz2 cygnal-f7c978d50fb7f510864ff4770fa7793a47a0b613.zip |
More POSIX stream corner cases.
* libc/stdio/findfp.c (__sinit): Open stderr read/write.
* libc/stdio/fdopen.c (_fdopen_r): Set O_APPEND on fd when
requested.
* libc/stdio64/fdopen64.c (_fdopen64_r): Likewise.
Diffstat (limited to 'newlib/libc/stdio/fdopen.c')
-rw-r--r-- | newlib/libc/stdio/fdopen.c | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/newlib/libc/stdio/fdopen.c b/newlib/libc/stdio/fdopen.c index f4fc551c4..aa764c372 100644 --- a/newlib/libc/stdio/fdopen.c +++ b/newlib/libc/stdio/fdopen.c @@ -29,7 +29,7 @@ ANSI_SYNOPSIS FILE *fdopen(int <[fd]>, const char *<[mode]>); FILE *_fdopen_r(struct _reent *<[reent]>, int <[fd]>, const char *<[mode]>); - + TRAD_SYNOPSIS #include <stdio.h> FILE *fdopen(<[fd]>, <[mode]>) @@ -96,17 +96,14 @@ _DEFUN(_fdopen_r, (ptr, fd, mode), _flockfile (fp); fp->_flags = flags; - /* - * If opened for appending, but underlying descriptor - * does not have O_APPEND bit set, assert __SAPP so that - * __swrite() will lseek to end before each write. - */ - if ((oflags & O_APPEND) + /* POSIX recommends setting the O_APPEND bit on fd to match append + streams. Someone may later clear O_APPEND on fileno(fp), but the + stream must still remain in append mode. Rely on __sflags + setting __SAPP properly. */ #ifdef HAVE_FCNTL - && !(fdflags & O_APPEND) + if ((oflags & O_APPEND) && !(fdflags & O_APPEND)) + _fcntl_r (ptr, fd, F_SETFL, fdflags | O_APPEND); #endif - ) - fp->_flags |= __SAPP; fp->_file = fd; fp->_cookie = (_PTR) fp; |