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/findfp.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/findfp.c')
-rw-r--r-- | newlib/libc/stdio/findfp.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/newlib/libc/stdio/findfp.c b/newlib/libc/stdio/findfp.c index 43f02ba5f..4f613e537 100644 --- a/newlib/libc/stdio/findfp.c +++ b/newlib/libc/stdio/findfp.c @@ -204,16 +204,21 @@ _DEFUN(__sinit, (s), std (s->_stdin, __SRD, 0, s); - /* on platforms that have true file system I/O, we can verify whether stdout - is an interactive terminal or not. For all other platforms, we will - default to line buffered mode here. */ + /* On platforms that have true file system I/O, we can verify + whether stdout is an interactive terminal or not, as part of + __smakebuf on first use of the stream. For all other platforms, + we will default to line buffered mode here. Technically, POSIX + requires both stdin and stdout to be line-buffered, but tradition + leaves stdin alone on systems without fcntl. */ #ifdef HAVE_FCNTL std (s->_stdout, __SWR, 1, s); #else std (s->_stdout, __SWR | __SLBF, 1, s); #endif - std (s->_stderr, __SWR | __SNBF, 2, s); + /* POSIX requires stderr to be opened for reading and writing, even + when the underlying fd 2 is write-only. */ + std (s->_stderr, __SRW | __SNBF, 2, s); __sinit_lock_release (); } |