diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2020-05-07 02:58:28 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2020-05-07 02:58:28 +0900 |
commit | 545d2ab7d2f318007dea6b9370b9e97c9ff36824 (patch) | |
tree | 7a29d76459abe077c30d80086f3574c5c0cf2363 /tool | |
parent | ce00fda9254887388b15a3a9ff505d3473cecf57 (diff) | |
download | ruby-545d2ab7d2f318007dea6b9370b9e97c9ff36824.tar.gz |
leakchecker.rb: try `lsof`
Diffstat (limited to 'tool')
-rw-r--r-- | tool/lib/leakchecker.rb | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/tool/lib/leakchecker.rb b/tool/lib/leakchecker.rb index a94d7a79b2..222b9ec3c8 100644 --- a/tool/lib/leakchecker.rb +++ b/tool/lib/leakchecker.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true class LeakChecker + @@try_lsof = nil # not-tried-yet + def initialize @fd_info = find_fds @tempfile_info = find_tempfiles @@ -74,7 +76,7 @@ class LeakChecker end (h[fd] ||= []) << [io, autoclose, inspect] } - fd_leaked.each {|fd| + fd_leaked.select! {|fd| str = ''.dup pos = nil if h[fd] @@ -105,8 +107,13 @@ class LeakChecker end puts "Leaked file descriptor: #{test_name}: #{fd}#{str}" puts " The IO was created at #{pos}" if pos + true } - #system("lsof -p #$$") if !fd_leaked.empty? + unless fd_leaked.empty? + unless @@try_lsof == false + @@try_lsof |= system("lsof -p #$$", out: MiniTest::Unit.output) + end + end h.each {|fd, list| next if list.length <= 1 if 1 < list.count {|io, autoclose, inspect| autoclose } |