aboutsummaryrefslogtreecommitdiffstats
path: root/io.c
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2016-04-07 21:46:44 +0300
committerArnold D. Robbins <arnold@skeeve.com>2016-04-07 21:46:44 +0300
commit658ede8ca657fe56c7ea6b0a3a1bd89fb858d26d (patch)
tree928465fc4f72e2467451cf774d8dd96fdb958927 /io.c
parent82dec6932ed868d9466d23ac5956e09594707dd2 (diff)
downloadegawk-658ede8ca657fe56c7ea6b0a3a1bd89fb858d26d.tar.gz
egawk-658ede8ca657fe56c7ea6b0a3a1bd89fb858d26d.tar.bz2
egawk-658ede8ca657fe56c7ea6b0a3a1bd89fb858d26d.zip
Fix race condition in fatal errors for one end closed on two way pipe.
Diffstat (limited to 'io.c')
-rw-r--r--io.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/io.c b/io.c
index fe1261aa..3a5748b2 100644
--- a/io.c
+++ b/io.c
@@ -212,8 +212,6 @@
#define INCREMENT_REC(X) X++
#endif
-typedef enum { CLOSE_ALL, CLOSE_TO, CLOSE_FROM } two_way_close_type;
-
/* Several macros to make the code a bit clearer. */
#define at_eof(iop) (((iop)->flag & IOP_AT_EOF) != 0)
#define has_no_data(iop) ((iop)->dataend == NULL)
@@ -1170,7 +1168,7 @@ do_close(int nargs)
/* close_rp --- separate function to just do closing */
-static int
+int
close_rp(struct redirect *rp, two_way_close_type how)
{
int status = 0;
@@ -2475,6 +2473,7 @@ do_getline_redir(int into_variable, enum redirval redirtype)
}
return make_number((AWKNUM) -1.0);
} else if ((rp->flag & RED_TWOWAY) != 0 && rp->iop == NULL) {
+ (void) close_rp(rp, CLOSE_ALL);
fatal(_("getline: attempt to read from closed read end of two-way pipe"));
}
iop = rp->iop;