diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2016-04-05 21:41:39 +0300 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2016-04-05 21:41:39 +0300 |
commit | db6e8faca70e60d2fa80e0affda3d9bef1e82eae (patch) | |
tree | 2ede6812410f1bfdba4e098a3d9dd92d725232f1 /builtin.c | |
parent | 2adf64c7b99ec6e8d1e4689b6484ace5295580b6 (diff) | |
parent | 1b5d1b8870cb0ac1c4b99f6cf67e3277427df864 (diff) | |
download | egawk-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.c | 21 |
1 files changed, 18 insertions, 3 deletions
@@ -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 |