Created
February 26, 2014 17:04
-
-
Save ixti/9233743 to your computer and use it in GitHub Desktop.
Chained trap in Ruby
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
module Kernel | |
def chained_trap(signal, &block) | |
oldproc = trap signal do |*args| | |
block[*args] do | |
trap signal, oldproc | |
Process.kill signal, 0 | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment