# \[BUG\] errno == 0 at IO#pos on DOSISH

**URL:** <https://www.ruby-forum.com/t/bug-errno-0-at-io-pos-on-dosish/117582>\
**Category:** Development\
**Created:** [October 18, 2007, 8:12am UTC](https://www.ruby-forum.com/t/bug-errno-0-at-io-pos-on-dosish/117582 "2007-10-18T08:12:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![nobu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/e9c0ed/32.png) [@nobu](https://www.ruby-forum.com/u/nobu)\
**Post date:** [October 18, 2007, 8:12am UTC](https://www.ruby-forum.com/t/bug-errno-0-at-io-pos-on-dosish/117582/1 "2007-10-18T08:12:39Z")

</div>

e$B$J$+$@$G$9!#e(B

[http://pc11.2ch.net/test/read.cgi/tech/1188014743/716](http://pc11.2ch.net/test/read.cgi/tech/1188014743/716) e$B$G8+3]$1$?e(B  
e$B$N$G$9$,!“e(BDOSISHe$B$J%7%9%F%`$G2~9T%3!\<%I$,e(BLFe$B$N%U%!%$%k$rFI$b$&$H$9e(B  
e$B$k$H!”$\*$+$7$J$3$H$K$J$k$h$&$G$9!#e(B

$ ./ruby -v -e ‘p ARGF.pos; p ARGF.eof?; p ARGF.pos’ COPYING  
ruby 1.8.6 (2007-10-18 revision 13735) [i386-mingw32]  
0  
false  
-e:1: [BUG] rb\_sys\_fail(COPYING) - errno == 0  
ruby 1.8.6 (2007-10-18) [i386-mingw32]

$ ./ruby -v -e ‘p ARGF.getc; p ARGF.pos’ COPYING  
ruby 1.8.6 (2007-10-18 revision 13735) [i386-mingw32]  
82  
-e:1: [BUG] rb\_sys\_fail(COPYING) - errno == 0  
ruby 1.8.6 (2007-10-18) [i386-mingw32]

e$B$3$l$O!"e(BVC runtimee$B$Ne(Bstdioe$B$Oe(Btext modee$B$NJQ49$re(Bfile  
descriptore$B%l%Ye(B  
e$B%k$KG$$;$F$$$k$?$a!“e(Bfseek()e$B$NCf$G$O!”:o$i$l$?$+$bCN$l$J$$%G!\<%?e(B  
e$B$rN`?d$7$F7k2L$rJd@5$7$F$$$k$?$a$G$9!#e(B

e$B:,K\E\*$K$O!“e(BVCe$B$Ne(Bstdioe$B$N@\_7W$G$Oe(BCR+LFe$B0J30$N2~9T$r4^$`%U%!%$%k$KBPe(B  
e$B$9$ke(Bseek/telle$B$NF0:n$OITDj$H$$$&$3$H$,$”$k$N$G$9$,!“0[\>o=_N;$7$Fe(B  
e$B$7$^$&$N$O$“$s$^$j$J$N$G!”$H$j$"$($:e(Berrnoe$B$b%A%'%C%/$9$k$h$&$K$7e(B  
e$B$F$_$/!”$H$$$&$N$O$I$&$G$7$g$&$+!#e(B

# Index: io.c

— io.c (revision 13735)  
+++ io.c (working copy)  
@@ -246,4 +246,5 @@ flush\_before\_seek(fptr)  
io\_fflush(GetWriteFile(fptr), fptr);  
}

- errno = 0;  
return fptr;  
}  
@@ -669,5 +670,5 @@ rb\_io\_tell(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);  
}  
@@ -684,5 +685,5 @@ rb\_io\_seek(io, offset, whence)  
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);  
clearerr(fptr-\>f);
