aboutsummaryrefslogtreecommitdiffstats
path: root/builtin.c
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2017-03-20 21:24:51 +0200
committerArnold D. Robbins <arnold@skeeve.com>2017-03-20 21:24:51 +0200
commita9b388f5902d8d06eeb2e742c7cea3c8f49cc2d0 (patch)
tree4e9465ca331406b17e32d2861e7095e935a0b06f /builtin.c
parent39c46265139aa8faf87160b30710876bde4c6ba9 (diff)
parentefc7e96c876ccf3b83ab3249eca852a0292ff943 (diff)
downloadegawk-a9b388f5902d8d06eeb2e742c7cea3c8f49cc2d0.tar.gz
egawk-a9b388f5902d8d06eeb2e742c7cea3c8f49cc2d0.tar.bz2
egawk-a9b388f5902d8d06eeb2e742c7cea3c8f49cc2d0.zip
Merge branch 'master' into feature/api-parser
Diffstat (limited to 'builtin.c')
-rw-r--r--builtin.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/builtin.c b/builtin.c
index 2acd9928..b92eb19d 100644
--- a/builtin.c
+++ b/builtin.c
@@ -133,7 +133,6 @@ wrerror:
if (fp == stdout && errno == EPIPE)
gawk_exit(EXIT_FATAL);
-
/* otherwise die verbosely */
if ((rp != NULL) ? is_non_fatal_redirect(rp->value, strlen(rp->value)) : is_non_fatal_std(fp))
update_ERRNO_int(errno);
@@ -245,13 +244,19 @@ do_fflush(int nargs)
return make_number((AWKNUM) status);
}
fp = rp->output.fp;
- if (fp != NULL)
+ if (fp != NULL) {
status = rp->output.gawk_fflush(fp, rp->output.opaque);
- else if ((rp->flag & RED_TWOWAY) != 0)
+
+ if (status != 0) {
+ if (! is_non_fatal_redirect(tmp->stptr, tmp->stlen))
+ fatal(_("fflush: cannot flush file `%.*s': %s"),
+ len, file, strerror(errno));
+ }
+ } else if ((rp->flag & RED_TWOWAY) != 0)
warning(_("fflush: cannot flush: two-way pipe `%.*s' has closed write end"),
len, file);
} else if ((fp = stdfile(tmp->stptr, tmp->stlen)) != NULL) {
- status = fflush(fp);
+ status = (non_fatal_flush_std_file(fp) == false);
} else {
status = -1;
warning(_("fflush: `%.*s' is not an open file, pipe or co-process"), len, file);
@@ -2148,9 +2153,7 @@ do_system(int nargs)
cmd[tmp->stlen] = '\0';
os_restore_mode(fileno(stdin));
-#ifdef SIGPIPE
- signal(SIGPIPE, SIG_DFL);
-#endif
+ set_sigpipe_to_default();
status = system(cmd);
/*
@@ -2176,9 +2179,7 @@ do_system(int nargs)
if ((BINMODE & BINMODE_INPUT) != 0)
os_setbinmode(fileno(stdin), O_BINARY);
-#ifdef SIGPIPE
- signal(SIGPIPE, SIG_IGN);
-#endif
+ ignore_sigpipe();
cmd[tmp->stlen] = save;
}