Skip to content

Commit

Permalink
Improved signal handling.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Dec 23, 2024
1 parent 1b1ff07 commit 411ea4f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lib/async/container/controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -205,13 +205,13 @@ def run
end
end
end
rescue Interrupt
self.stop
rescue Terminate
self.stop(false)
ensure
self.stop(false)
end
rescue Interrupt
self.stop
rescue Terminate
self.stop(false)
ensure
self.stop(false)
end

private def with_signal_handlers
Expand All @@ -233,7 +233,7 @@ def run
::Thread.current.raise(Hangup)
end

::Thread.handle_interrupt(SignalException => :on_blocking) do
::Thread.handle_interrupt(SignalException => :never) do
yield
end
ensure
Expand Down
1 change: 1 addition & 0 deletions lib/async/container/group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ def wait_for_children(duration = nil)
end
end

# Wait for a child process to exit OR a signal to be received.
def select(duration)
::Thread.handle_interrupt(SignalException => :immediate) do
readable, _, _ = ::IO.select(@running.keys, nil, nil, duration)
Expand Down

0 comments on commit 411ea4f

Please sign in to comment.