diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2016-05-12 21:43:48 +0300 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2016-05-12 21:43:48 +0300 |
commit | b2b81414cc6f4c2c4b5539a680c074c8c4592af7 (patch) | |
tree | 2061a3559e8e878d875a0135ac7ebae89448caa9 /io.c | |
parent | fec6265dfb087ecc8a26a9d8917bcd05bb4b1860 (diff) | |
download | egawk-b2b81414cc6f4c2c4b5539a680c074c8c4592af7.tar.gz egawk-b2b81414cc6f4c2c4b5539a680c074c8c4592af7.tar.bz2 egawk-b2b81414cc6f4c2c4b5539a680c074c8c4592af7.zip |
Fix issues with SIGPIPE.
Diffstat (limited to 'io.c')
-rw-r--r-- | io.c | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -894,9 +894,15 @@ redirect(NODE *redir_exp, int redirtype, int *errflg) (void) flush_io(); os_restore_mode(fileno(stdin)); +#ifdef SIGPIPE + signal(SIGPIPE, SIG_DFL); +#endif 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"); @@ -2403,9 +2409,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"); |