Skip to content

Commit

Permalink
Waiter: USR2 is JRuby-supported
Browse files Browse the repository at this point in the history
  - to have a user-facing feature signal, we pick one that can be used on JVM
  • Loading branch information
olleolleolle committed Nov 20, 2016
1 parent 1eeed8f commit 4611615
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions lib/hutch/waiter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ def self.supported_signals_of(list)
end

SHUTDOWN_SIGNALS = supported_signals_of(%w(QUIT TERM INT)).freeze
USER_SIGNALS = supported_signals_of(%w(TTIN USR1 USR2)).freeze
# We have chosen a JRuby-supported signal
USER_SIGNALS = supported_signals_of(%w(USR2)).freeze
REGISTERED_SIGNALS = (SHUTDOWN_SIGNALS + USER_SIGNALS).freeze

def self.wait_until_signaled
Expand Down Expand Up @@ -51,17 +52,15 @@ def handle_shutdown_signal(sig)
# @raises ContinueProcessingSignals
def handle_user_signal(sig)
case sig
when 'TTIN' then handle_ttin
when 'USR1', 'USR2' then handle_user_defined_signals
else
raise "Assertion failed - unhandled signal: #{sig.inspect}"
when 'USR2' then handle_usr2
else raise "Assertion failed - unhandled signal: #{sig.inspect}"
end
raise ContinueProcessingSignals
end

private

def handle_ttin
def handle_usr2
Thread.list.each do |thread|
logger.warn "Thread TID-#{thread.object_id.to_s(36)} #{thread['label']}"
if thread.backtrace
Expand All @@ -72,10 +71,6 @@ def handle_ttin
end
end

def handle_user_defined_signals
logger.warn "SIG#{sig} noted. Continuing." # TODO: Find useful behavior
end

attr_accessor :sig_read, :sig_write

def wait_for_signal
Expand Down

0 comments on commit 4611615

Please sign in to comment.