diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2016-04-06 05:54:19 +0300 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2016-04-06 05:54:19 +0300 |
commit | cfb773bb093dadfa715816c75d438f97e387e71a (patch) | |
tree | 293aedc7402a7c1e25af42f235133ce9caa77b25 /builtin.c | |
parent | db6e8faca70e60d2fa80e0affda3d9bef1e82eae (diff) | |
download | egawk-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.c | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -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; |