aboutsummaryrefslogtreecommitdiffstats
path: root/builtin.c
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2016-04-06 05:54:19 +0300
committerArnold D. Robbins <arnold@skeeve.com>2016-04-06 05:54:19 +0300
commitcfb773bb093dadfa715816c75d438f97e387e71a (patch)
tree293aedc7402a7c1e25af42f235133ce9caa77b25 /builtin.c
parentdb6e8faca70e60d2fa80e0affda3d9bef1e82eae (diff)
downloadegawk-cfb773bb093dadfa715816c75d438f97e387e71a.tar.gz
egawk-cfb773bb093dadfa715816c75d438f97e387e71a.tar.bz2
egawk-cfb773bb093dadfa715816c75d438f97e387e71a.zip
Allow r/w for a partially closed two-way pipe to be nonfatal.
Diffstat (limited to 'builtin.c')
-rw-r--r--builtin.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/builtin.c b/builtin.c
index b3756ebc..e07bdb53 100644
--- a/builtin.c
+++ b/builtin.c
@@ -1679,6 +1679,10 @@ do_printf(int nargs, int redirtype)
rp = redirect(redir_exp, redirtype, & errflg, true);
if (rp != NULL) {
if ((rp->flag & RED_TWOWAY) != 0 && rp->output.fp == NULL) {
+ if (is_non_fatal_redirect(redir_exp->stptr)) {
+ update_ERRNO_int(EBADF);
+ return;
+ }
fatal(_("printf: attempt to write to closed write end of two-way pipe"));
}
fp = rp->output.fp;
@@ -2159,6 +2163,10 @@ do_print(int nargs, int redirtype)
rp = redirect(redir_exp, redirtype, & errflg, true);
if (rp != NULL) {
if ((rp->flag & RED_TWOWAY) != 0 && rp->output.fp == NULL) {
+ if (is_non_fatal_redirect(redir_exp->stptr)) {
+ update_ERRNO_int(EBADF);
+ return;
+ }
fatal(_("print: attempt to write to closed write end of two-way pipe"));
}
fp = rp->output.fp;
@@ -2233,6 +2241,10 @@ do_print_rec(int nargs, int redirtype)
rp = redirect(redir_exp, redirtype, & errflg, true);
if (rp != NULL) {
if ((rp->flag & RED_TWOWAY) != 0 && rp->output.fp == NULL) {
+ if (is_non_fatal_redirect(redir_exp->stptr)) {
+ update_ERRNO_int(EBADF);
+ return;
+ }
fatal(_("print: attempt to write to closed write end of two-way pipe"));
}
fp = rp->output.fp;