diff options
author | tjr <tjr@FreeBSD.org> | 2002-12-19 09:53:26 +0000 |
---|---|---|
committer | tjr <tjr@FreeBSD.org> | 2002-12-19 09:53:26 +0000 |
commit | 80abd67f591992ea14440a958fd23e23e71275ec (patch) | |
tree | bc7f0601bf214c5e63115618af3226ea6224f612 /lib/libc/stdio/perror.c | |
parent | 93b0a6ff838ddcf6424849b3b6f3516ba29e845a (diff) | |
download | FreeBSD-src-80abd67f591992ea14440a958fd23e23e71275ec.zip FreeBSD-src-80abd67f591992ea14440a958fd23e23e71275ec.tar.gz |
Write the message to stderr, not file descriptor 2, so that perror()
writes to the correct stream if stderr has been redirected with freopen().
Diffstat (limited to 'lib/libc/stdio/perror.c')
-rw-r--r-- | lib/libc/stdio/perror.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/libc/stdio/perror.c b/lib/libc/stdio/perror.c index 162d49e..29016f7 100644 --- a/lib/libc/stdio/perror.c +++ b/lib/libc/stdio/perror.c @@ -46,6 +46,8 @@ __FBSDID("$FreeBSD$"); #include <stdio.h> #include <string.h> #include "un-namespace.h" +#include "libc_private.h" +#include "local.h" void perror(s) @@ -70,5 +72,9 @@ perror(s) v++; v->iov_base = "\n"; v->iov_len = 1; - (void)_writev(STDERR_FILENO, iov, (v - iov) + 1); + FLOCKFILE(stderr); + __sflush(stderr); + (void)_writev(stderr->_file, iov, (v - iov) + 1); + stderr->_flags &= ~__SOFF; + FUNLOCKFILE(stderr); } |