aboutsummaryrefslogtreecommitdiff
path: root/libio
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@gmail.com>2011-05-21 00:42:06 -0400
committerUlrich Drepper <drepper@gmail.com>2011-05-21 00:42:06 -0400
commitaec84f53952315ac1bd91036e37113d9cb3a303b (patch)
treec14c6c1a134a245094506dad430c951493b2eeed /libio
parent34a9094f49241ebb72084c536cf468fd51ebe3ec (diff)
downloadglibc-aec84f53952315ac1bd91036e37113d9cb3a303b.zip
glibc-aec84f53952315ac1bd91036e37113d9cb3a303b.tar.gz
glibc-aec84f53952315ac1bd91036e37113d9cb3a303b.tar.bz2
Set stream errors in more cases
Also avoid unnecessarily setting errno when testing for TTY.
Diffstat (limited to 'libio')
-rw-r--r--libio/filedoalloc.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/libio/filedoalloc.c b/libio/filedoalloc.c
index ca02dbe..4f62dcd 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