aboutsummaryrefslogtreecommitdiff
path: root/jim-aio.c
diff options
context:
space:
mode:
authorSteve Bennett <steveb@workware.net.au>2011-06-22 09:18:03 +1000
committerSteve Bennett <steveb@workware.net.au>2011-06-22 09:19:29 +1000
commit0833e0816f84d76c655e47fa5fd09bb3c1e11f34 (patch)
treeec3aed580437926dd8073fab2ffb00a51ffb87ab /jim-aio.c
parent26b7dc6cfe26e29f19301da17ac8677263c14c3b (diff)
downloadjimtcl-0833e0816f84d76c655e47fa5fd09bb3c1e11f34.zip
jimtcl-0833e0816f84d76c655e47fa5fd09bb3c1e11f34.tar.gz
jimtcl-0833e0816f84d76c655e47fa5fd09bb3c1e11f34.tar.bz2
aio: Ignore error indication on eof
Reading from a pipe can set both ferror() and feof(). In this case, feof() takes precedence. Signed-off-by: Steve Bennett <steveb@workware.net.au>
Diffstat (limited to 'jim-aio.c')
-rw-r--r--jim-aio.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/jim-aio.c b/jim-aio.c
index e5e8898..8f7b12e 100644
--- a/jim-aio.c
+++ b/jim-aio.c
@@ -344,12 +344,15 @@ static int aio_cmd_read(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
break;
}
/* Check for error conditions */
- if (ferror(af->fp) && errno != EAGAIN) {
- /* I/O error */
- Jim_FreeNewObj(interp, objPtr);
- JimAioSetError(interp, af->filename);
+ if (ferror(af->fp)) {
clearerr(af->fp);
- return JIM_ERR;
+ /* eof and EAGAIN are not error conditions */
+ if (!feof(af->fp) && errno != EAGAIN) {
+ /* I/O error */
+ Jim_FreeNewObj(interp, objPtr);
+ JimAioSetError(interp, af->filename);
+ return JIM_ERR;
+ }
}
if (nonewline) {
int len;