Module: Utils::Interrupts Private
- Defined in:
- utils/interrupts.rb
This module is part of a private API. This module may only be used in the Homebrew/brew repository. Third parties should avoid using this module if possible, as it may be removed or changed without warning.
Class Method Summary collapse
Class Method Details
.ignore(&_block) ⇒ T.type_parameter(:U)
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'utils/interrupts.rb', line 9 def self.ignore(&_block) @mutex.synchronize do interrupted = T.let(false, T::Boolean) old_sigint_handler = Signal.trap(:INT) do interrupted = true $stderr.print "\n" $stderr.puts "One sec, cleaning up..." end begin yield ensure Signal.trap(:INT, old_sigint_handler) Kernel.raise Interrupt if interrupted end end end |