-
-
Save schneems/41a30bd72153c6782746 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def prepend_handler(signal, &handler) | |
previous = Signal.trap(signal) do | |
previous = -> { raise SignalException, signal } unless previous.respond_to?(:call) | |
handler.call(previous) | |
end | |
end | |
prepend_handler("TERM") do |old| | |
do_something | |
old.call | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've handled this by resetting the old handler and then resending the signal: