diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2013-10-24 22:03:09 +0300 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2013-10-24 22:03:09 +0300 |
commit | 25520aab6144927a20d501c0396e9597f36fc871 (patch) | |
tree | 1a8b237e152873b5a789f10865c11a5ed1e0c3cc /io.c | |
parent | eb152bbe507aef92ece4a301863263818fb50a04 (diff) | |
download | egawk-25520aab6144927a20d501c0396e9597f36fc871.tar.gz egawk-25520aab6144927a20d501c0396e9597f36fc871.tar.bz2 egawk-25520aab6144927a20d501c0396e9597f36fc871.zip |
Improve handling of writes to dead pipes.
Diffstat (limited to 'io.c')
-rw-r--r-- | io.c | 18 |
1 files changed, 12 insertions, 6 deletions
@@ -1261,12 +1261,15 @@ flush_io() int status = 0; errno = 0; + /* we don't warn about stdout/stderr if EPIPE, but we do error exit */ if (fflush(stdout)) { - warning(_("error writing standard output (%s)"), strerror(errno)); + if (errno != EPIPE) + warning(_("error writing standard output (%s)"), strerror(errno)); status++; } if (fflush(stderr)) { - warning(_("error writing standard error (%s)"), strerror(errno)); + if (errno != EPIPE) + warning(_("error writing standard error (%s)"), strerror(errno)); status++; } for (rp = red_head; rp != NULL; rp = rp->next) @@ -1316,13 +1319,16 @@ close_io(bool *stdio_problem) * them, we just flush them, and do that across the board. */ *stdio_problem = false; - if (fflush(stdout)) { - warning(_("error writing standard output (%s)"), strerror(errno)); + /* we don't warn about stdout/stderr if EPIPE, but we do error exit */ + if (fflush(stdout) != 0) { + if (errno != EPIPE) + warning(_("error writing standard output (%s)"), strerror(errno)); status++; *stdio_problem = true; } - if (fflush(stderr)) { - warning(_("error writing standard error (%s)"), strerror(errno)); + if (fflush(stderr) != 0) { + if (errno != EPIPE) + warning(_("error writing standard error (%s)"), strerror(errno)); status++; *stdio_problem = true; } |