Module: Itsi::SignalTrap
- Defined in:
- lib/itsi/server/signal_trap.rb
Overview
This trap is necessary for debuggers and similar which intercept certain signals then attempt to restore these to the previous signal when finished. If the previous signal handler was registered in native code, this restoration doesn’t work as expected and the native signal handler is lost. We intercept restored signals here and reinstate the Itsi server signal handlers (if the server is still running).
Constant Summary collapse
- DEFAULT_SIGNALS =
["DEFAULT", "", nil].freeze
- INTERCEPTED_SIGNALS =
["INT"].freeze
Instance Method Summary collapse
Instance Method Details
#server_running? ⇒ Boolean
21 22 23 |
# File 'lib/itsi/server/signal_trap.rb', line 21 def server_running? Itsi::Server.respond_to?(:running?) && Itsi::Server.running? end |
#trap(signal, *args, &block) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/itsi/server/signal_trap.rb', line 12 def trap(signal, *args, &block) unless INTERCEPTED_SIGNALS.include?(signal.to_s) && block.nil? && server_running? return super(signal, *args, &block) end Itsi::Server.reset_signal_handlers nil end |