Skip to content

Instantly share code, notes, and snippets.

@ixti
Created February 26, 2014 17:04
Show Gist options
  • Save ixti/9233743 to your computer and use it in GitHub Desktop.
Save ixti/9233743 to your computer and use it in GitHub Desktop.
Chained trap in Ruby
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