aboutsummaryrefslogtreecommitdiffstats
path: root/io.c
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2017-03-24 10:05:58 +0300
committerArnold D. Robbins <arnold@skeeve.com>2017-03-24 10:05:58 +0300
commit7ab6cf2fbf203bf01e0d3bcd736d8676cfdef9a7 (patch)
tree81e5fe11d516f602967965a0121e383e1f7da486 /io.c
parenta993b9f04076e4c1a9cef66a2955077d87abd138 (diff)
parentbc97284df48d79d57450aae746c08f8d55d3a57a (diff)
downloadegawk-7ab6cf2fbf203bf01e0d3bcd736d8676cfdef9a7.tar.gz
egawk-7ab6cf2fbf203bf01e0d3bcd736d8676cfdef9a7.tar.bz2
egawk-7ab6cf2fbf203bf01e0d3bcd736d8676cfdef9a7.zip
Merge branch 'master' into feature/api-mpfr
Diffstat (limited to 'io.c')
-rw-r--r--io.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/io.c b/io.c
index 0da27575..00a0ba3c 100644
--- a/io.c
+++ b/io.c
@@ -1407,6 +1407,7 @@ non_fatal_flush_std_file(FILE *fp)
: _("fflush: cannot flush standard error: %s"),
strerror(errno));
} else {
+ update_ERRNO_int(errno);
warning(fp == stdout
? _("error writing standard output (%s)")
: _("error writing standard error (%s)"),
@@ -1427,26 +1428,34 @@ flush_io()
int status = 0;
errno = 0;
- if (! non_fatal_flush_std_file(stdout))
+ if (! non_fatal_flush_std_file(stdout)) // ERRNO updated
status++;
errno = 0;
- if (! non_fatal_flush_std_file(stderr))
+ if (! non_fatal_flush_std_file(stderr)) // ERRNO updated
status++;
+
// now for all open redirections
for (rp = red_head; rp != NULL; rp = rp->next) {
+ void (*messagefunc)(const char *mesg, ...) = fatal;
+
/* flush both files and pipes, what the heck */
if ((rp->flag & RED_WRITE) != 0 && rp->output.fp != NULL) {
if (rp->output.gawk_fflush(rp->output.fp, rp->output.opaque) != 0) {
+ update_ERRNO_int(errno);
+
+ if (is_non_fatal_redirect(rp->value, strlen(rp->value)))
+ messagefunc = warning;
+
if ((rp->flag & RED_PIPE) != 0)
- warning(_("pipe flush of `%s' failed (%s)."),
+ messagefunc(_("pipe flush of `%s' failed (%s)."),
rp->value, strerror(errno));
else if ((rp->flag & RED_TWOWAY) != 0)
- warning(_("co-process flush of pipe to `%s' failed (%s)."),
+ messagefunc(_("co-process flush of pipe to `%s' failed (%s)."),
rp->value, strerror(errno));
else
- warning(_("file flush of `%s' failed (%s)."),
+ messagefunc(_("file flush of `%s' failed (%s)."),
rp->value, strerror(errno));
status++;
}