aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2017-04-11 22:24:41 +0300
committerArnold D. Robbins <arnold@skeeve.com>2017-04-11 22:24:41 +0300
commit967e4b9ec9e1b7cc7ca9968f6fe822f3b1155f53 (patch)
tree25d98488c29b77686670ea66c6647701493de63a
parent75981b3d127c3c97329b5b085bddebf3b40e797d (diff)
parentbd6dc293e35fdeac05bd1577593e111fd09d22b7 (diff)
downloadegawk-967e4b9ec9e1b7cc7ca9968f6fe822f3b1155f53.tar.gz
egawk-967e4b9ec9e1b7cc7ca9968f6fe822f3b1155f53.tar.bz2
egawk-967e4b9ec9e1b7cc7ca9968f6fe822f3b1155f53.zip
Merge branch 'master' into feature/api-mpfr
-rw-r--r--ChangeLog8
-rw-r--r--awk.h5
-rw-r--r--io.c12
-rw-r--r--main.c8
4 files changed, 33 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 5a8cdc43..3e4aeb6f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+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>
Cause EPIPE errors to stdout to generate a real SIGPIPE.
diff --git a/awk.h b/awk.h
index 3e2f0bb9..dd50b843 100644
--- a/awk.h
+++ b/awk.h
@@ -1987,5 +1987,10 @@ make_number_node(unsigned int tp)
#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
diff --git a/io.c b/io.c
index b00f4db4..f854ec5a 100644
--- a/io.c
+++ b/io.c
@@ -1399,6 +1399,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
@@ -1494,12 +1498,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++;
diff --git a/main.c b/main.c
index 530d37fd..b6841d57 100644
--- a/main.c
+++ b/main.c
@@ -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));