summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2017-03-27 20:32:24 +0300
committerArnold D. Robbins <arnold@skeeve.com>2017-03-27 20:32:24 +0300
commit70f73831de55d63263839d5fa6ac44dbc2c38491 (patch)
treec9cc008a1ca0747ce4e679e21f5f46b1d3bd1af7
parentc5d46e712f917385b2291c6acb3fc323b4b8d16c (diff)
parent5b7042ea0a68d41c4fbd0d6228f77975ebf8c38b (diff)
downloadgawk-70f73831de55d63263839d5fa6ac44dbc2c38491.tar.gz
Merge branch 'master' into feature/api-parser
-rw-r--r--ChangeLog9
-rw-r--r--awk.h2
-rw-r--r--builtin.c4
-rw-r--r--io.c2
-rw-r--r--main.c5
-rw-r--r--vms/ChangeLog10
-rw-r--r--vms/vmstest.com4
7 files changed, 28 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index 25ed67a4..a06a21f7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2017-03-27 Arnold D. Robbins <arnold@skeeve.com>
+
+ Cause EPIPE errors to stdout to generate a real SIGPIPE.
+
+ * awk.h (die_via_sigpipe): New macro.
+ * builtin.c (efwrite): Use it.
+ * io.c (non_fatal_flush_std_file): Ditto.
+ * main.c (usage): Ditto.
+
2017-03-25 Arnold D. Robbins <arnold@skeeve.com>
* io.c (flush_io): Use r_fatal and r_warning for messagefunc
diff --git a/awk.h b/awk.h
index 43d2713c..934fe25b 100644
--- a/awk.h
+++ b/awk.h
@@ -1968,7 +1968,9 @@ erealloc_real(void *ptr, size_t count, const char *where, const char *var, const
#ifdef SIGPIPE
#define ignore_sigpipe() signal(SIGPIPE, SIG_IGN)
#define set_sigpipe_to_default() signal(SIGPIPE, SIG_DFL)
+#define die_via_sigpipe() (signal(SIGPIPE, SIG_DFL), kill(getpid(), SIGPIPE))
#else
#define ignore_sigpipe()
#define set_sigpipe_to_default()
+#define die_via_sigpipe() exit(EXIT_FATAL)
#endif
diff --git a/builtin.c b/builtin.c
index 0f2c62f8..e2143b36 100644
--- a/builtin.c
+++ b/builtin.c
@@ -129,9 +129,9 @@ wrerror:
if (errno == 0 || errno == EINVAL)
w32_maybe_set_errno();
#endif
- /* die silently on EPIPE to stdout */
+ /* for stdout, die with a real SIGPIPE, like other awks */
if (fp == stdout && errno == EPIPE)
- gawk_exit(EXIT_SUCCESS); // a la SIGPIPE
+ die_via_sigpipe();
/* otherwise die verbosely */
if ((rp != NULL) ? is_non_fatal_redirect(rp->value, strlen(rp->value)) : is_non_fatal_std(fp))
diff --git a/io.c b/io.c
index 85025e45..1ed40aab 100644
--- a/io.c
+++ b/io.c
@@ -1401,7 +1401,7 @@ non_fatal_flush_std_file(FILE *fp)
if (is_fatal) {
if (errno == EPIPE)
- exit(EXIT_SUCCESS); // simulate SIGPIPE
+ die_via_sigpipe();
else
fatal(fp == stdout
? _("fflush: cannot flush standard output: %s")
diff --git a/main.c b/main.c
index f348171c..9c404b21 100644
--- a/main.c
+++ b/main.c
@@ -633,7 +633,10 @@ By default it reads standard input and writes standard output.\n\n"), fp);
warning(_("error writing standard output (%s)"), strerror(errno));
else if (fp == stderr)
warning(_("error writing standard error (%s)"), strerror(errno));
- }
+ } else if (errno == SIGPIPE)
+ die_via_sigpipe();
+
+ // some other problem than SIGPIPE
exit(EXIT_FAILURE);
}
diff --git a/vms/ChangeLog b/vms/ChangeLog
index a2354c19..af9a9539 100644
--- a/vms/ChangeLog
+++ b/vms/ChangeLog
@@ -1,11 +1,15 @@
+2017-03-25 John E. Malmberg <wb8tyw@qsl.net>
+
+ * vmstest.com: Fix argarray teset.
+
2016-12-22 John E. Malmberg <wb8tyw@qsl.net>
- * vmsbuild.com, descrip.mms:
- Update for new [.support] directory.
+ * vmsbuild.com, descrip.mms:
+ Update for new [.support] directory.
2016-11-24 John E. Malmberg <wb8tyw@qsl.net>
- * gawk_verb.com: correct location for gawk executable.
+ * gawk_verb.com: correct location for gawk executable.
2016-10-24 John E. Malmberg <wb8tyw@qsl.net>
diff --git a/vms/vmstest.com b/vms/vmstest.com
index aa96ceba..a10cd3f5 100644
--- a/vms/vmstest.com
+++ b/vms/vmstest.com
@@ -920,8 +920,10 @@ $ return
$
$argarray: echo "argarray"
$ test_class = "basic"
+$ copy sys$disk:[]argarray.in sys$disk:[]argarray.input
+$ purge sys$disk:[]argarray.input
$ define/User TEST "test" !this is useless...
-$ gawk -f argarray.awk ./argarray.in - >_argarray.tmp
+$ gawk -f argarray.awk ./argarray.input - >_argarray.tmp
just a test
$ if f$search("sys$disk:[]_''test'.tmp;2") .nes. ""
$ then