Make ignore_interrupts thread-safe.

This commit is contained in:
Markus Reiter 2024-07-14 11:41:38 -04:00
parent b9da669ef2
commit bcded854ce
No known key found for this signature in database
GPG Key ID: 245293B51702655B

View File

@ -349,7 +349,10 @@ module Kernel
end end
end end
IGNORE_INTERRUPTS_MUTEX = Thread::Mutex.new.freeze
def ignore_interrupts(_opt = nil) def ignore_interrupts(_opt = nil)
IGNORE_INTERRUPTS_MUTEX.synchronize do
# rubocop:disable Style/GlobalVars # rubocop:disable Style/GlobalVars
$ignore_interrupts_nesting_level = 0 unless defined?($ignore_interrupts_nesting_level) $ignore_interrupts_nesting_level = 0 unless defined?($ignore_interrupts_nesting_level)
$ignore_interrupts_nesting_level += 1 $ignore_interrupts_nesting_level += 1
@ -374,6 +377,7 @@ module Kernel
end end
# rubocop:enable Style/GlobalVars # rubocop:enable Style/GlobalVars
end end
end
def redirect_stdout(file) def redirect_stdout(file)
out = $stdout.dup out = $stdout.dup