diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2017-03-24 10:06:09 +0300 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2017-03-24 10:06:09 +0300 |
commit | 95997cea4be726f78f24215b4c6427fbf337cdb2 (patch) | |
tree | f3f9dd3bcecfaa1413fd41f11b49c3cd2446de6f /io.c | |
parent | de35ebb8a343a6756ee5b45a6f0958626c17982c (diff) | |
parent | bc97284df48d79d57450aae746c08f8d55d3a57a (diff) | |
download | egawk-95997cea4be726f78f24215b4c6427fbf337cdb2.tar.gz egawk-95997cea4be726f78f24215b4c6427fbf337cdb2.tar.bz2 egawk-95997cea4be726f78f24215b4c6427fbf337cdb2.zip |
Merge branch 'master' into feature/api-parser
Diffstat (limited to 'io.c')
-rw-r--r-- | io.c | 19 |
1 files changed, 14 insertions, 5 deletions
@@ -1408,6 +1408,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)"), @@ -1428,26 +1429,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++; } |