Make ignore_interrupts thread-safe.
This commit is contained in:
parent
b9da669ef2
commit
bcded854ce
@ -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
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user