mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
leakchecker.rb: search /dev/fd too
It is more popular than /proc/self/fd.
This commit is contained in:
parent
3a6dad9d8b
commit
039a8ef786
1 changed files with 12 additions and 12 deletions
|
@ -35,19 +35,19 @@ class LeakChecker
|
|||
if IO.respond_to?(:console) and (m = IO.method(:console)).arity.nonzero?
|
||||
m[:close]
|
||||
end
|
||||
fd_dir = "/proc/self/fd"
|
||||
if File.directory?(fd_dir)
|
||||
fds = Dir.open(fd_dir) {|d|
|
||||
a = d.grep(/\A\d+\z/, &:to_i)
|
||||
if d.respond_to? :fileno
|
||||
a -= [d.fileno]
|
||||
end
|
||||
a
|
||||
}
|
||||
fds.sort
|
||||
else
|
||||
[]
|
||||
%w"/proc/self/fd /dev/fd".each do |fd_dir|
|
||||
if File.directory?(fd_dir)
|
||||
fds = Dir.open(fd_dir) {|d|
|
||||
a = d.grep(/\A\d+\z/, &:to_i)
|
||||
if d.respond_to? :fileno
|
||||
a -= [d.fileno]
|
||||
end
|
||||
a
|
||||
}
|
||||
return fds.sort
|
||||
end
|
||||
end
|
||||
[]
|
||||
end
|
||||
|
||||
def check_fd_leak(test_name)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue