From aec84f53952315ac1bd91036e37113d9cb3a303b Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Sat, 21 May 2011 00:42:06 -0400 Subject: Set stream errors in more cases Also avoid unnecessarily setting errno when testing for TTY. --- stdio-common/perror.c | 7 ++++++- stdio-common/vfprintf.c | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'stdio-common') diff --git a/stdio-common/perror.c b/stdio-common/perror.c index 3ee6152..dedc922 100644 --- a/stdio-common/perror.c +++ b/stdio-common/perror.c @@ -1,4 +1,5 @@ -/* Copyright (C) 1991-1993,1997,1998,2000-2005 Free Software Foundation, Inc. +/* Copyright (C) 1991-1993,1997,1998,2000-2005,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 @@ -73,6 +74,10 @@ perror (const char *s) position. Since the stderr stream wasn't used so far we just write to the descriptor. */ perror_internal (fp, s, errnum); + + if (_IO_ferror_unlocked (fp)) + stderr->_flags |= _IO_ERR_SEEN; + /* Close the stream. */ fclose (fp); } diff --git a/stdio-common/vfprintf.c b/stdio-common/vfprintf.c index cfa4c30..753a5ac 100644 --- a/stdio-common/vfprintf.c +++ b/stdio-common/vfprintf.c @@ -52,6 +52,7 @@ CHECK_FILE (S, -1); \ if (S->_flags & _IO_NO_WRITES) \ { \ + S->_flags |= _IO_ERR_SEEN; \ __set_errno (EBADF); \ return -1; \ } \ -- cgit v1.1