diff options
author | Takashi Yano <takashi.yano@nifty.ne.jp> | 2018-07-05 17:01:26 +0300 |
---|---|---|
committer | Jeff Johnston <jjohnstn@redhat.com> | 2018-07-05 22:33:49 +0300 |
commit | 6a3e08a53ec996b37639a18dc98123e23531409c (patch) | |
tree | 789b9eeeb1cd56348628e115e3368deae7e8a7a2 /newlib/libc/signal/psignal.c | |
parent | 0ce27ecd08355620e73c89f8cf6b71f597b75f9c (diff) |
Fix newlib functions perror()/psignal() not to use writev().
This fix is for some platforms which do not have writev().
*perror.c: Use _write_r() instead of writev().
*psignal.c: Use write() insetad of writev().
Revise commit: d4f4e7ae1be1bcf8c021f2b0865aafc16b338aa3
Diffstat (limited to 'newlib/libc/signal/psignal.c')
-rw-r--r-- | newlib/libc/signal/psignal.c | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/newlib/libc/signal/psignal.c b/newlib/libc/signal/psignal.c index 9a584869d..f847ab2c8 100644 --- a/newlib/libc/signal/psignal.c +++ b/newlib/libc/signal/psignal.c @@ -32,37 +32,37 @@ Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>, #include <_ansi.h> #include <stdio.h> #include <string.h> -#include <sys/uio.h> +#include <unistd.h> -#define ADD(str) \ +#define WRITE_STR(str) \ { \ - v->iov_base = (void *)(str); \ - v->iov_len = strlen (v->iov_base); \ - v ++; \ - iov_cnt ++; \ + const char *p = (str); \ + size_t len = strlen (p); \ + while (len) \ + { \ + ssize_t len1 = write (fileno (stderr), p, len); \ + if (len1 < 0) \ + break; \ + len -= len1; \ + p += len1; \ + } \ } void psignal (int sig, const char *s) { - struct iovec iov[4]; - struct iovec *v = iov; - int iov_cnt = 0; - + fflush (stderr); if (s != NULL && *s != '\0') { - ADD (s); - ADD (": "); + WRITE_STR (s); + WRITE_STR (": "); } - ADD (strsignal (sig)); + WRITE_STR (strsignal (sig)); #ifdef __SCLE - ADD ((stderr->_flags & __SCLE) ? "\r\n" : "\n"); + WRITE_STR ((stderr->_flags & __SCLE) ? "\r\n" : "\n"); #else - ADD ("\n"); + WRITE_STR ("\n"); #endif - - fflush (stderr); - writev (fileno (stderr), iov, iov_cnt); } |