Actions
Bug #3198
closedO_APPEND for redirect fd is ignored on windows
Bug #3198:
O_APPEND for redirect fd is ignored on windows
Description
=begin
Windows7 で、リダイレクト用にファイルをオープンする時
O_APPEND を渡しても無視されます。
$ 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"
以下のようなパッチを書きました。特に反対がなければコミットさせて頂きます。
rb_w32_open で処理することも考えましたが、おそらくリダイレクト以外では
O_APPEND が効くのではないかと思うので、とりあえず process.c で処理しました。
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]);
=end
Actions