From: James Tucker Date: 2010-07-23T00:43:04+09:00 Subject: [ruby-core:31447] Re: [Backport #3602] stdout not set in rubyw.exe, causes silent failures On 22 Jul 2010, at 15:59, Justin Fitzsimmons wrote: > Backport #3602: stdout not set in rubyw.exe, causes silent failures > http://redmine.ruby-lang.org/issues/show/3602 > > Author: Justin Fitzsimmons > Status: Open, Priority: Normal > > Attempting to write anything to stdout will cause the program to silently crash when executed with rubyw.exe on windows. > > The problem is trivial to duplicate: > > Source: > > f = File.new("test.txt", "w") > f.write("failure") > f.close > puts "Hello, World" > f = File.new("test.txt", "w") > f.write("success") > f.close > > ------------------------------ > > Execution output: > > C:\>ruby test.rb > Hello, World > > C:\>type test.txt > success > > > C:\>rubyw test.rb > > C:\>type test.txt > failure > > -----END OUTPUT---------------- > > This bug is not present in the 1.9.1 build of ruby for windows. A workaround is available, by providing a valid file descriptor for stdout, e.g. $stdout = File.new("stdout.txt", "w"). I might recommend a sane default being actually to set them to IO.new("NUL:", ..) on win32. Defaulting to anything else either causes silent crashes due to ruby code, or potentially due to filesystem access issues.