aboutsummaryrefslogtreecommitdiffstats
path: root/io.c
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2016-05-12 22:39:48 +0300
committerArnold D. Robbins <arnold@skeeve.com>2016-05-12 22:39:48 +0300
commitd7b4254cbf5f70d430e21f4f8ca90e354e251bac (patch)
treeebead5b02dae267232b6e597612704f9a3697235 /io.c
parent9205d5d6fd20ad78918b44100063ade0b1374ede (diff)
parent29f8ff8ee26d1c5c3fad9129786687c745322494 (diff)
downloadegawk-d7b4254cbf5f70d430e21f4f8ca90e354e251bac.tar.gz
egawk-d7b4254cbf5f70d430e21f4f8ca90e354e251bac.tar.bz2
egawk-d7b4254cbf5f70d430e21f4f8ca90e354e251bac.zip
Merge branch 'gawk-4.1-stable'
Diffstat (limited to 'io.c')
-rw-r--r--io.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/io.c b/io.c
index b81ebf3f..7e97b953 100644
--- a/io.c
+++ b/io.c
@@ -900,6 +900,9 @@ redirect_string(const char *str, size_t explen, bool not_string,
(void) flush_io();
os_restore_mode(fileno(stdin));
+#ifdef SIGPIPE
+ signal(SIGPIPE, SIG_DFL);
+#endif
/*
* Don't check failure_fatal; see input pipe below.
* Note that the failure happens upon failure to fork,
@@ -909,6 +912,9 @@ redirect_string(const char *str, size_t explen, bool not_string,
if ((rp->output.fp = popen(str, binmode("w"))) == NULL)
fatal(_("can't open pipe `%s' for output (%s)"),
str, strerror(errno));
+#ifdef SIGPIPE
+ signal(SIGPIPE, SIG_IGN);
+#endif
/* set close-on-exec */
os_close_on_exec(fileno(rp->output.fp), str, "pipe", "to");
@@ -2532,9 +2538,18 @@ gawk_popen(const char *cmd, struct redirect *rp)
FILE *current;
os_restore_mode(fileno(stdin));
+#ifdef SIGPIPE
+ signal(SIGPIPE, SIG_DFL);
+#endif
+
current = popen(cmd, binmode("r"));
+
if ((BINMODE & BINMODE_INPUT) != 0)
os_setbinmode(fileno(stdin), O_BINARY);
+#ifdef SIGPIPE
+ signal(SIGPIPE, SIG_IGN);
+#endif
+
if (current == NULL)
return NULL;
os_close_on_exec(fileno(current), cmd, "pipe", "from");