diff options
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | awk.h | 5 | ||||
-rw-r--r-- | io.c | 12 | ||||
-rw-r--r-- | main.c | 8 |
4 files changed, 33 insertions, 0 deletions
@@ -8,6 +8,14 @@ * field.c (fw_parse_field): Edit comment about resetting shift state. * gawkapi.h (awk_fieldwidth_info_t): Make white space more uniform. +2017-04-08 Eli Zaretskii <eliz@gnu.org> + + * main.c (usage, copyleft) [__MINGW32__]: + * io.c (non_fatal_flush_std_file, close_io) [__MINGW32__]: Call + w32_maybe_set_errno to correctly set errno to EPIPE when appropriate. + + * awk.h (die_via_sigpipe) [__MINGW32__]: MinGW-specific definition. + 2017-03-27 Arnold D. Robbins <arnold@skeeve.com> * field.c (parse_field_func_t): New typedef. Used as needed. @@ -1972,5 +1972,10 @@ erealloc_real(void *ptr, size_t count, const char *where, const char *var, const #else #define ignore_sigpipe() #define set_sigpipe_to_default() +#ifdef __MINGW32__ +/* 0xC0000008 is EXCEPTION_INVALID_HANDLE, somewhat appropriate for EPIPE */ +#define die_via_sigpipe() exit(0xC0000008) +#else /* !__MINGW32__ */ #define die_via_sigpipe() exit(EXIT_FATAL) +#endif /* !__MINGW32__ */ #endif @@ -1400,6 +1400,10 @@ non_fatal_flush_std_file(FILE *fp) bool is_fatal = ! is_non_fatal_std(fp); if (is_fatal) { +#ifdef __MINGW32__ + if (errno == 0 || errno == EINVAL) + w32_maybe_set_errno(); +#endif if (errno == EPIPE) die_via_sigpipe(); else @@ -1495,12 +1499,20 @@ close_io(bool *stdio_problem) *stdio_problem = false; /* we don't warn about stdout/stderr if EPIPE, but we do error exit */ if (fflush(stdout) != 0) { +#ifdef __MINGW32__ + if (errno == 0 || errno == EINVAL) + w32_maybe_set_errno(); +#endif if (errno != EPIPE) warning(_("error writing standard output (%s)"), strerror(errno)); status++; *stdio_problem = true; } if (fflush(stderr) != 0) { +#ifdef __MINGW32__ + if (errno == 0 || errno == EINVAL) + w32_maybe_set_errno(); +#endif if (errno != EPIPE) warning(_("error writing standard error (%s)"), strerror(errno)); status++; @@ -627,6 +627,10 @@ By default it reads standard input and writes standard output.\n\n"), fp); fflush(fp); if (ferror(fp)) { +#ifdef __MINGW32__ + if (errno == 0 || errno == EINVAL) + w32_maybe_set_errno(); +#endif /* don't warn about stdout/stderr if EPIPE, but do error exit */ if (errno == EPIPE) die_via_sigpipe(); @@ -673,6 +677,10 @@ along with this program. If not, see http://www.gnu.org/licenses/.\n"); fflush(stdout); if (ferror(stdout)) { +#ifdef __MINGW32__ + if (errno == 0 || errno == EINVAL) + w32_maybe_set_errno(); +#endif /* don't warn about stdout if EPIPE, but do error exit */ if (errno != EPIPE) warning(_("error writing standard output (%s)"), strerror(errno)); |