summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
Diffstat (limited to 'io.c')
-rw-r--r--io.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/io.c b/io.c
index 13e70860f0..ded34f07de 100644
--- a/io.c
+++ b/io.c
@@ -318,6 +318,7 @@ flush_before_seek(rb_io_t *fptr)
{
io_fflush(fptr);
io_unread(fptr);
+ errno = 0;
return fptr;
}
@@ -780,7 +781,7 @@ rb_io_tell(VALUE io)
GetOpenFile(io, fptr);
pos = io_tell(fptr);
- if (pos < 0) rb_sys_fail(fptr->path);
+ if (pos < 0 && errno) rb_sys_fail(fptr->path);
return OFFT2NUM(pos);
}
@@ -793,7 +794,7 @@ rb_io_seek(VALUE io, VALUE offset, int whence)
pos = NUM2OFFT(offset);
GetOpenFile(io, fptr);
pos = io_seek(fptr, pos, whence);
- if (pos < 0) rb_sys_fail(fptr->path);
+ if (pos < 0 && errno) rb_sys_fail(fptr->path);
return INT2FIX(0);
}