aboutsummaryrefslogtreecommitdiffstats
path: root/builtin.c
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2016-04-05 21:41:39 +0300
committerArnold D. Robbins <arnold@skeeve.com>2016-04-05 21:41:39 +0300
commitdb6e8faca70e60d2fa80e0affda3d9bef1e82eae (patch)
tree2ede6812410f1bfdba4e098a3d9dd92d725232f1 /builtin.c
parent2adf64c7b99ec6e8d1e4689b6484ace5295580b6 (diff)
parent1b5d1b8870cb0ac1c4b99f6cf67e3277427df864 (diff)
downloadegawk-db6e8faca70e60d2fa80e0affda3d9bef1e82eae.tar.gz
egawk-db6e8faca70e60d2fa80e0affda3d9bef1e82eae.tar.bz2
egawk-db6e8faca70e60d2fa80e0affda3d9bef1e82eae.zip
Merge branch 'gawk-4.1-stable'
Diffstat (limited to 'builtin.c')
-rw-r--r--builtin.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/builtin.c b/builtin.c
index 9bd8e5eb..b3756ebc 100644
--- a/builtin.c
+++ b/builtin.c
@@ -241,6 +241,9 @@ do_fflush(int nargs)
fp = rp->output.fp;
if (fp != NULL)
status = rp->output.gawk_fflush(fp, rp->output.opaque);
+ else if ((rp->flag & RED_TWOWAY) != 0)
+ warning(_("fflush: cannot flush: two-way pipe `%s' has closed write end"),
+ file);
} else if ((fp = stdfile(tmp->stptr, tmp->stlen)) != NULL) {
status = fflush(fp);
} else {
@@ -1674,8 +1677,12 @@ do_printf(int nargs, int redirtype)
if (redir_exp->type != Node_val)
fatal(_("attempt to use array `%s' in a scalar context"), array_vname(redir_exp));
rp = redirect(redir_exp, redirtype, & errflg, true);
- if (rp != NULL)
+ if (rp != NULL) {
+ if ((rp->flag & RED_TWOWAY) != 0 && rp->output.fp == NULL) {
+ fatal(_("printf: attempt to write to closed write end of two-way pipe"));
+ }
fp = rp->output.fp;
+ }
else if (errflg) {
update_ERRNO_int(errflg);
return;
@@ -2150,8 +2157,12 @@ do_print(int nargs, int redirtype)
if (redir_exp->type != Node_val)
fatal(_("attempt to use array `%s' in a scalar context"), array_vname(redir_exp));
rp = redirect(redir_exp, redirtype, & errflg, true);
- if (rp != NULL)
+ if (rp != NULL) {
+ if ((rp->flag & RED_TWOWAY) != 0 && rp->output.fp == NULL) {
+ fatal(_("print: attempt to write to closed write end of two-way pipe"));
+ }
fp = rp->output.fp;
+ }
else if (errflg) {
update_ERRNO_int(errflg);
return;
@@ -2220,8 +2231,12 @@ do_print_rec(int nargs, int redirtype)
if (redirtype != 0) {
redir_exp = TOP();
rp = redirect(redir_exp, redirtype, & errflg, true);
- if (rp != NULL)
+ if (rp != NULL) {
+ if ((rp->flag & RED_TWOWAY) != 0 && rp->output.fp == NULL) {
+ fatal(_("print: attempt to write to closed write end of two-way pipe"));
+ }
fp = rp->output.fp;
+ }
DEREF(redir_exp);
decr_sp();
} else