summaryrefslogtreecommitdiff
path: root/tool
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2020-05-06 10:09:29 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2020-05-06 10:09:29 +0900
commit039a8ef78673f851e39b43980376c2af40d5cbbc (patch)
tree41e4cf0c0b9429f4e7c17534404d830b99cb73af /tool
parent3a6dad9d8bcd973fc05d19f70702cba486195bc0 (diff)
leakchecker.rb: search /dev/fd too
It is more popular than /proc/self/fd.
Diffstat (limited to 'tool')
-rw-r--r--tool/lib/leakchecker.rb24
1 files changed, 12 insertions, 12 deletions
diff --git a/tool/lib/leakchecker.rb b/tool/lib/leakchecker.rb
index 03eb5391c4..293ebe6a9a 100644
--- a/tool/lib/leakchecker.rb
+++ b/tool/lib/leakchecker.rb
@@ -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)