Skip to content

Commit

Permalink
Improve Pitchfork::Info IO tracking
Browse files Browse the repository at this point in the history
First avoid setting the IO instance as weakmap value as it
requires more work for Ruby and also can run into
ruby/ruby#7540

Second allow both `$std*` and `STD*` to remain open.
  • Loading branch information
byroot committed Sep 20, 2023
1 parent 75afc32 commit 06da91a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/pitchfork/info.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class << self

def keep_io(io)
raise ArgumentError, "#{io.inspect} doesn't respond to :to_io" unless io.respond_to?(:to_io)
@kept_ios[io] = io
@kept_ios[io] = true
io
end

Expand All @@ -22,9 +22,9 @@ def keep_ios(ios)
end

def close_all_ios!
ignored_ios = [$stdin, $stdout, $stderr]
ignored_ios = [$stdin, $stdout, $stderr, STDIN, STDOUT, STDERR].uniq.compact

@kept_ios.each_value do |io_like|
@kept_ios.each_key do |io_like|
ignored_ios << (io_like.is_a?(IO) ? io_like : io_like.to_io)
end

Expand Down

0 comments on commit 06da91a

Please sign in to comment.