Actions
Bug #3290
closedFile descriptors not closed when all IO objects are collected
Bug #3290:
File descriptors not closed when all IO objects are collected
Status:
Rejected
Assignee:
-
Target version:
-
ruby -v:
ruby 1.9.1p129 (2009-05-12 revision 23412) [i386-mswin32]
Backport:
Description
=begin
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.
=end
Actions