ruby-changes:61030
From: Nobuyoshi <ko1@a...>
Date: Thu, 7 May 2020 05:23:09 +0900 (JST)
Subject: [ruby-changes:61030] 545d2ab7d2 (master): leakchecker.rb: try `lsof`
https://git.ruby-lang.org/ruby.git/commit/?id=545d2ab7d2 From 545d2ab7d2f318007dea6b9370b9e97c9ff36824 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Thu, 7 May 2020 02:58:28 +0900 Subject: leakchecker.rb: try `lsof` diff --git a/tool/lib/leakchecker.rb b/tool/lib/leakchecker.rb index a94d7a7..222b9ec 100644 --- a/tool/lib/leakchecker.rb +++ b/tool/lib/leakchecker.rb @@ -1,5 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/tool/lib/leakchecker.rb#L1 # 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 https://github.com/ruby/ruby/blob/trunk/tool/lib/leakchecker.rb#L76 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 https://github.com/ruby/ruby/blob/trunk/tool/lib/leakchecker.rb#L107 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 } -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/