Disallow nested ignore_interrupts.
This commit is contained in:
parent
3c8497647e
commit
27a70a40c2
@ -353,13 +353,9 @@ module Kernel
|
|||||||
|
|
||||||
def ignore_interrupts(quiet: false)
|
def ignore_interrupts(quiet: false)
|
||||||
IGNORE_INTERRUPTS_MUTEX.synchronize do
|
IGNORE_INTERRUPTS_MUTEX.synchronize do
|
||||||
# rubocop:disable Style/GlobalVars
|
interrupted = false
|
||||||
$ignore_interrupts_nesting_level = 0 unless defined?($ignore_interrupts_nesting_level)
|
|
||||||
$ignore_interrupts_nesting_level += 1
|
|
||||||
|
|
||||||
$ignore_interrupts_interrupted = false unless defined?($ignore_interrupts_interrupted)
|
|
||||||
old_sigint_handler = trap(:INT) do
|
old_sigint_handler = trap(:INT) do
|
||||||
$ignore_interrupts_interrupted = true
|
interrupted = true
|
||||||
|
|
||||||
unless quiet
|
unless quiet
|
||||||
$stderr.print "\n"
|
$stderr.print "\n"
|
||||||
@ -372,14 +368,9 @@ module Kernel
|
|||||||
ensure
|
ensure
|
||||||
trap(:INT, old_sigint_handler)
|
trap(:INT, old_sigint_handler)
|
||||||
|
|
||||||
$ignore_interrupts_nesting_level -= 1
|
raise Interrupt if interrupted
|
||||||
if $ignore_interrupts_nesting_level == 0 && $ignore_interrupts_interrupted
|
|
||||||
$ignore_interrupts_interrupted = false
|
|
||||||
raise Interrupt
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
# rubocop:enable Style/GlobalVars
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def redirect_stdout(file)
|
def redirect_stdout(file)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user