From: Heesob Park Date: 2010-01-03T12:31:01+09:00 Subject: [ruby-core:27376] [Bug #2549] Redirected stdout don't work on child process on Windows Bug #2549: Redirected stdout don't work on child process on Windows http://redmine.ruby-lang.org/issues/show/2549 Author: Heesob Park Status: Open, Priority: Normal ruby -v: ruby 1.9.1p243 (2009-07-16 revision 24175) [i386-mingw32] A file created in Ruby and redirected to stdout don't work properly on child process in 1.9.x. c:\work>type test.rb STDOUT.reopen(File.open('out.txt', 'w+')) system('ruby -v') File.open('out.txt','a+'){|f|f.puts('EOF')} In 1.8.6 c:\work>type out.txt ruby 1.8.6 (2009-08-04 patchlevel 383) [i386-mingw32] EOF In 1.9.1p243 and 1.9.2dev c:\work>type out.txt EOF I noticed the root cause is FILE_FLAG_OVERLAPPED handling of ruby 1.9.x. I guess it is related with the select and native thread supporting on Windows. But the child process cannot handle the overlapped I/O on most cases. In short, the inheritable file handle must not opened with the FILE_FLAG_OVERLAPPED flag. Regards, Park Heesob ---------------------------------------- http://redmine.ruby-lang.org