Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakashi Yano <takashi.yano@nifty.ne.jp>2018-07-03 12:04:31 +0300
committerCorinna Vinschen <corinna@vinschen.de>2018-07-04 15:17:28 +0300
commitd4f4e7ae1be1bcf8c021f2b0865aafc16b338aa3 (patch)
tree9b1a336ed5bc812abf9f1d882d4d8f75317c1fc7 /newlib/libc/signal
parent1c1cec9cdff8e71deabb896081215b58ca8b16b6 (diff)
Fix a bug of perror()/psignal() that changes the orientation of stderr.
* perror.c: Fix the problem that perror() changes the orientation of stderr to byte-oriented mode if stderr is not oriented yet. * psignal.c: Ditto.
Diffstat (limited to 'newlib/libc/signal')
-rw-r--r--newlib/libc/signal/psignal.c30
1 files changed, 27 insertions, 3 deletions
diff --git a/newlib/libc/signal/psignal.c b/newlib/libc/signal/psignal.c
index 602714f49..9a584869d 100644
--- a/newlib/libc/signal/psignal.c
+++ b/newlib/libc/signal/psignal.c
@@ -32,13 +32,37 @@ Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
#include <_ansi.h>
#include <stdio.h>
#include <string.h>
+#include <sys/uio.h>
+
+#define ADD(str) \
+{ \
+ v->iov_base = (void *)(str); \
+ v->iov_len = strlen (v->iov_base); \
+ v ++; \
+ iov_cnt ++; \
+}
void
psignal (int sig,
const char *s)
{
+ struct iovec iov[4];
+ struct iovec *v = iov;
+ int iov_cnt = 0;
+
if (s != NULL && *s != '\0')
- fprintf (stderr, "%s: %s\n", s, strsignal (sig));
- else
- fprintf (stderr, "%s\n", strsignal (sig));
+ {
+ ADD (s);
+ ADD (": ");
+ }
+ ADD (strsignal (sig));
+
+#ifdef __SCLE
+ ADD ((stderr->_flags & __SCLE) ? "\r\n" : "\n");
+#else
+ ADD ("\n");
+#endif
+
+ fflush (stderr);
+ writev (fileno (stderr), iov, iov_cnt);
}