aboutsummaryrefslogtreecommitdiffstats
path: root/io.c
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2013-05-30 21:20:49 +0300
committerArnold D. Robbins <arnold@skeeve.com>2013-05-30 21:20:49 +0300
commita25b9b39ac2c49b822328414240061f6d22ddef2 (patch)
tree7c402a087491fdb168828602eba91230cd0a66ff /io.c
parent9dfa2ba854a2d7b7835274cf60a31294664612f3 (diff)
downloadegawk-a25b9b39ac2c49b822328414240061f6d22ddef2.tar.gz
egawk-a25b9b39ac2c49b822328414240061f6d22ddef2.tar.bz2
egawk-a25b9b39ac2c49b822328414240061f6d22ddef2.zip
Minor fix in io.c.
Diffstat (limited to 'io.c')
-rw-r--r--io.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/io.c b/io.c
index 333d8704..4f682622 100644
--- a/io.c
+++ b/io.c
@@ -2912,8 +2912,18 @@ iop_finish(IOBUF *iop)
if (isdir)
iop->errcode = EISDIR;
else {
+ struct stat sbuf;
+
iop->errcode = EIO;
- (void) close(iop->public.fd);
+ /*
+ * Extensions can supply values that are not
+ * INVALID_HANDLE but that are also not real
+ * file descriptors. So check the fd before
+ * trying to close it, which avoids errors
+ * on some operating systems.
+ */
+ if (fstat(iop->public.fd, & sbuf) == 0)
+ (void) close(iop->public.fd);
iop->public.fd = INVALID_HANDLE;
}
/*