diff options
author | Ulrich Drepper <drepper@gmail.com> | 2011-05-21 00:42:06 -0400 |
---|---|---|
committer | Ulrich Drepper <drepper@gmail.com> | 2011-05-21 00:42:06 -0400 |
commit | aec84f53952315ac1bd91036e37113d9cb3a303b (patch) | |
tree | c14c6c1a134a245094506dad430c951493b2eeed /libio | |
parent | 34a9094f49241ebb72084c536cf468fd51ebe3ec (diff) | |
download | glibc-aec84f53952315ac1bd91036e37113d9cb3a303b.tar.gz glibc-aec84f53952315ac1bd91036e37113d9cb3a303b.tar.xz glibc-aec84f53952315ac1bd91036e37113d9cb3a303b.zip |
Set stream errors in more cases
Also avoid unnecessarily setting errno when testing for TTY.
Diffstat (limited to 'libio')
-rw-r--r-- | libio/filedoalloc.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/libio/filedoalloc.c b/libio/filedoalloc.c index ca02dbeb34..4f62dcd910 100644 --- a/libio/filedoalloc.c +++ b/libio/filedoalloc.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1993, 1997, 2001, 2002 Free Software Foundation, Inc. +/* Copyright (C) 1993, 1997, 2001, 2002, 2011 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -41,7 +41,7 @@ 4. Neither the name of the University nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. - + THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -74,6 +74,17 @@ # include <device-nrs.h> #endif + +static int +local_isatty (int fd) +{ + int save_errno = errno; + int res = isatty (fd); + __set_errno (save_errno); + return res; +} + + /* * Allocate a file buffer, or switch to unbuffered I/O. * Per the ANSI C standard, ALL tty devices default to line buffered. @@ -109,7 +120,7 @@ _IO_file_doallocate (fp) #ifdef DEV_TTY_P DEV_TTY_P (&st) || #endif - isatty (fp->_fileno)) + local_isatty (fp->_fileno)) fp->_flags |= _IO_LINE_BUF; } #if _IO_HAVE_ST_BLKSIZE |