From: Brian Candler Date: 2010-08-06T20:01:22+09:00 Subject: Re: Abstracting exception handling Martin Hansen wrote: > $! does not tell the difference between interrupt, terminate, > and quit (perhaps that could be fixed? - just a thought). It does for me. $ cat ert.rb at_exit { puts "Last exception was #{$!.inspect}" if $!; exit! } sleep 100 puts "Nothing happened" ### Ctrl-C: $ ruby ert.rb ^CLast exception was Interrupt ert.rb:2:in `sleep': Interrupt from ert.rb:2 ### kill -TERM (from another window): $ ruby ert.rb Last exception was # Terminated ### kill -QUIT: Last exception was # Quit This is with ruby 1.8.7 (2010-01-10 patchlevel 249) [x86_64-linux] under Ubuntu Lucid amd64. So I don't understand why you're trying to trap all of these signals, when they all cause the program to terminate, and they can all be distinguished in $!. But perhaps your platform behaves differently? Final note: inside your at_exit handler, you can use 'exit!' to prevent any further processing, i.e. the default output of the backtrace or signal. -- Posted via http://www.ruby-forum.com/.