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?
|
if IO.respond_to?(:console) and (m = IO.method(:console)).arity.nonzero?
|
||||||
m[:close]
|
m[:close]
|
||||||
end
|
end
|
||||||
fd_dir = "/proc/self/fd"
|
%w"/proc/self/fd /dev/fd".each do |fd_dir|
|
||||||
if File.directory?(fd_dir)
|
if File.directory?(fd_dir)
|
||||||
fds = Dir.open(fd_dir) {|d|
|
fds = Dir.open(fd_dir) {|d|
|
||||||
a = d.grep(/\A\d+\z/, &:to_i)
|
a = d.grep(/\A\d+\z/, &:to_i)
|
||||||
if d.respond_to? :fileno
|
if d.respond_to? :fileno
|
||||||
a -= [d.fileno]
|
a -= [d.fileno]
|
||||||
end
|
end
|
||||||
a
|
a
|
||||||
}
|
}
|
||||||
fds.sort
|
return fds.sort
|
||||||
else
|
end
|
||||||
[]
|
|
||||||
end
|
end
|
||||||
|
[]
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_fd_leak(test_name)
|
def check_fd_leak(test_name)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue