From: Tomas Matousek Date: 2010-05-14T11:11:51+09:00 Subject: [ruby-core:30233] [Bug #3290] File descriptors not closed when all IO objects are collected Bug #3290: File descriptors not closed when all IO objects are collected http://redmine.ruby-lang.org/issues/show/3290 Author: Tomas Matousek Status: Open, Priority: Normal ruby -v: ruby 1.9.1p129 (2009-05-12 revision 23412) [i386-mswin32] The following script should raise an exception (invalid descriptor) on line [2] since the file object that allocated it should have been collected on line [1]. The script actually writes "hello" to the file so it seems that Ruby is leaking file descriptors. def foo f = File.open("a.txt", "w+") fd = f.to_i f = nil fd end fd = foo 10.times { GC.start } # [1] g = IO.new(fd, "w+") # [2] g.write('hello') g.close --- The behavior is same in 1.8.6. ---------------------------------------- http://redmine.ruby-lang.org