From 0833e0816f84d76c655e47fa5fd09bb3c1e11f34 Mon Sep 17 00:00:00 2001 From: Steve Bennett Date: Wed, 22 Jun 2011 09:18:03 +1000 Subject: 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 --- jim-aio.c | 13 ++++++++----- 1 file 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; -- cgit v1.1