diff options
author | Steve Bennett <steveb@workware.net.au> | 2011-06-22 09:18:03 +1000 |
---|---|---|
committer | Steve Bennett <steveb@workware.net.au> | 2011-06-22 09:19:29 +1000 |
commit | 0833e0816f84d76c655e47fa5fd09bb3c1e11f34 (patch) | |
tree | ec3aed580437926dd8073fab2ffb00a51ffb87ab /jim-aio.c | |
parent | 26b7dc6cfe26e29f19301da17ac8677263c14c3b (diff) | |
download | jimtcl-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.c | 13 |
1 files changed, 8 insertions, 5 deletions
@@ -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; |