From b247ac086e60a6cee99ea1989277c5c66b0541de Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 6 May 2020 13:13:10 +0900 Subject: [PATCH] Ignore FDs kept by system library `getaddrinfo` on macOS seems keeping FDs to query host names internally. --- tool/lib/leakchecker.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tool/lib/leakchecker.rb b/tool/lib/leakchecker.rb index 293ebe6a9a..bd0e24ba2e 100644 --- a/tool/lib/leakchecker.rb +++ b/tool/lib/leakchecker.rb @@ -89,6 +89,19 @@ class LeakChecker }.sort.each {|s| str << s } + else + begin + io = IO.for_fd(fd, autoclose: false) + s = io.stat + rescue Errno::EBADF + # something un-stat-able + next + else + next if /darwin/ =~ RUBY_PLATFORM and [0, -1].include?(s.dev) + str << ' ' << s.inspect + ensure + io.close + end end puts "Leaked file descriptor: #{test_name}: #{fd}#{str}" puts " The IO was created at #{pos}" if pos