[Bug #3198] O_APPEND for redirect fd is ignored on windows

Bug #3198: O_APPEND for redirect fd is ignored on windows
http://redmine.ruby-lang.org/issues/show/3198

e$B5/I<<Te(B: _ wanabe
e$B%9%F!<%?%9e(B: Open, e$BM%@hEYe(B: Normal
ruby -v: ruby 1.9.2dev (2010-04-24 trunk 22784) [i386-mingw32]

Windows7 e$B$G!"%j%@%$%l%/%HMQ$K%U%!%$%k$r%*!<%W%s$9$k;~e(B
O_APPEND e$B$rEO$7$F$bL5;k$5$l$^$9!#e(B

$ cat test.rb
fname = “tmp.out”
File.delete fname if File.exist? fname
5.times do
system(“echo a”, STDOUT=>[fname,
File::WRONLY|File::CREAT|File::APPEND, 0644])
end
p IO.read(fname)

$ ruby -v test.rb
ruby 1.9.2dev (2010-04-24 trunk 22784) [i386-mingw32]
“a\n”

e$B0J2<$N$h$&$J%Q%C%A$r=q$-$^$7$?!#FC$KH?BP$,$J$1$l$P%3%_%C%H$5$;$FD:$-$^$9!#e(B
rb_w32_open
e$B$G=hM}$9$k$3$H$b9M$($^$7$?$,!“$*$=$i$/%j%@%$%l%/%H0J30$G$Oe(B
O_APPEND e$B$,8z$/$N$G$O$J$$$+$H;W$&$N$G!”$H$j$"$($:e(B process.c
e$B$G=hM}$7$^$7$?!#e(B

Index: process.c

— process.c (revision 27483)
+++ process.c (working copy)
@@ -2094,6 +2094,11 @@ run_exec_open(VALUE ary, VALUE save, char
*errmsg, size_t errmsg_buflen)
ERRMSG(“open”);
return -1;
}
+#if defined(_WIN32)

  • if (flags & O_APPEND) {
  •  lseek(fd2, 0, SEEK_END);
    
  • }
    +#endif
    while (i < RARRAY_LEN(ary) &&
    (elt = RARRAY_PTR(ary)[i], RARRAY_PTR(elt)[1] == param))
    {
    fd = FIX2INT(RARRAY_PTR(elt)[0]);

Bug #3198: O_APPEND for redirect fd is ignored on windows
http://redmine.ruby-lang.org/issues/show/3198

e$B5/I<<Te(B: _ wanabe
e$B%9%F!<%?%9e(B: Open, e$BM%@hEYe(B: Normal
ruby -v: ruby 1.9.2dev (2010-04-24 trunk 22784) [i386-mingw32]

Windows7 e$B$G!"%j%@%$%l%/%HMQ$K%U%!%$%k$r%*!<%W%s$9$k;~e(B
O_APPEND e$B$rEO$7$F$bL5;k$5$l$^$9!#e(B

e$B:,K\860x$O$J$s$J$N$G$7$g$&$+!)e(B

+#if defined(_WIN32)

  •   if (flags & O_APPEND) {
    
  •       lseek(fd2, 0, SEEK_END);
    
  •   }
    

+#endif

e$B%l%S%e!<$7$^$7$?!#e(Blseek(SEEK_END)e$B$@$HB>$N%W%m%;%9$H6%9g$7$?>l9g$Ke(B
e$BF1$8;v$,5/$-$^$9$,!"$3$l$OLdBj$J$$!)e(B

e$B$3$s$K$A$O!"$J$+$`$ie(B(e$B$&e(B)e$B$G$9!#e(B

In message “[ruby-dev:41055] Re: [Bug #3198] O_APPEND for redirect fd is
ignored on windows”
on Apr.25,2010 13:20:15, [email protected] wrote:

Windows7 e$B$G!"%j%@%$%l%/%HMQ$K%U%!%$%k$r%*!<%W%s$9$k;~e(B
O_APPEND e$B$rEO$7$F$bL5;k$5$l$^$9!#e(B

e$B:,K\860x$O$J$s$J$N$G$7$g$&$+!)e(B

fde$B$KIU?o$7$?%U%i%0$O;R%W%m%;%9$K<u$17Q$,$l$^$;$s!#e(B
e$B$@$C$F%U%!%$%k%G%9%/%j%W%?$J$s$F35G0e(BWindowse$B<+BN$K$O$J$$$s$@$be(B
e$B$s!#e(B

+#if defined(_WIN32)

  •   if (flags & O_APPEND) {
    
  •       lseek(fd2, 0, SEEK_END);
    
  •   }
    

+#endif

e$B%l%S%e!<$7$^$7$?!#e(Blseek(SEEK_END)e$B$@$HB>$N%W%m%;%9$H6%9g$7$?>l9g$Ke(B
e$BF1$8;v$,5/$-$^$9$,!"$3$l$OLdBj$J$$!)e(B

e$BHr$1F@$J$$$+$i$$$$$s$8$c$J$$$G$9$+$M!#e(B

e$B$=$l$G$O!#e(B

e$B$@$C$F%U%!%$%k%G%9%/%j%W%?$J$s$F35G0e(BWindowse$B<+BN$K$O$J$$$s$@$be(B
e$B$s!#e(B

e$B$"$"!"$J$k$[$I!#$J$C$H$/!#$9$$$^$;$s6u5$FI$a$F$^$;$s$G$7$?e(B
e$B$J$i$7$g$&$,$J$$$G$9$M!#e(B

e$B%A%1%C%He(B #3198 e$B$,99?7$5$l$^$7$?!#e(B (by _ wanabe)

e$B%+%F%4%je(B coree$B$K%;%C%He(B
Target version 1.9.xe$B$K%;%C%He(B

e$B%l%S%e!<$*$h$SJdB-$“$j$,$H$&$4$6$$$^$9!#e(B
e$B$=$N8e!”$3$N%Q%C%A$G$O=q$-9~$_A0$K4{$K%]%$%s%?$,KvHx$K0\F0$7$F$$$k>uBV$K$J$je(B
e$BFI$9~$;~$Ke(B O_APPEND
e$B$NF0:n$H0[$J$C$F$7$^$$$h$/$J$$!"$H$$$&$3$H$,$o$+$j$^$7$?$N$Ge(B
e$B>e$N%Q%C%A$O<h$j2<$2$^$9!#e(B

e$B$^$?!"e(B1.9.2 e$BA0$KAa5^$KD>$9$Y$-$H$b;W$($^$;$s$N$GH=JL$N$?$a$Ke(B
e$B%?!<%2%C%H$re(B 1.9.x e$B$K$7$F$*$-$^$9!#e(B

http://redmine.ruby-lang.org/issues/show/3198