lib/overcommit/interrupt_handler.rb
# Provide a way to allow a single Ctrl-C interrupt to happen and atomically
# re-enable interrupt protections once that interrupt is propagated.
#
# This prevents a race condition where code like the following:
#
#  begin
#    InterruptHandler.disable!
#    ... do stuff ...
#  rescue Interrupt
#    ... handle it ...
#  ensure
#    InterruptHandler.enable!
#  end
#
# ...could have the `enable!` call to the interrupt handler not called in
# the event another interrupt was received in between the interrupt being
# handled and the `ensure` block being entered.
#
# Thus you should always write:
#
#  begin
#    InterruptHandler.disable_until_finished_or_interrupted do
#      ... do stuff ...
#    end
#  rescue Interrupt
#    ... handle it ...
#  rescue
#    ... handle any other exceptions ...
#  end
Provide a way to allow a single Ctrl-C interrupt to happen and atomically
re-enable interrupt protections once that interrupt is propagated.

This prevents a race condition where code like the following.



could have the `enable!` call to the interrupt handler not called in
the event another interrupt was received in between the interrupt being
handled and the `ensure` block being entered.

Thus you should always write.

begin
InterruptHandler.disable_until_finished_or_interrupted do
do stuff
end
rescue Interrupt
handle it
rescue
handle any other exceptions
end
Provide a way to allow a single Ctrl - C interrupt to happen and atomically re - enable interrupt protections once that interrupt is propagated . This prevents a race condition where code like the following . could have the ` enable! ` call to the interrupt handler not called in the event another interrupt was received in between the interrupt being handled and the ` ensure ` block being entered . Thus you should always write . begin InterruptHandler . disable_until_finished_or_interrupted do do stuff end rescue Interrupt handle it rescue handle any other exceptions end
def disable_until_finished_or_interrupted
      instance.reenable_on_interrupt = true
      instance.isolate_signals = false
      yield
    ensure
      instance.isolate_signals = true
    end
def disable_until_finished_or_interrupted instance . reenable_on_interrupt = true instance . isolate_signals = false yield ensure instance . isolate_signals = true end
Provide a way to allow a single Ctrl-C interrupt to happen and atomically
re-enable interrupt protections once that interrupt is propagated.
Provide a way to allow a single Ctrl - C interrupt to happen and atomically re - enable interrupt protections once that interrupt is propagated .