From: Martin Hansen Date: 2010-06-21T21:48:02+09:00 Subject: Re: How to print exit status to a log file? > It seems there is a much simpler solution to what you want - you don't > even need a signal handler for this: > > $ ruby19 -e 'begin; sleep 60; rescue Exception => e; p e.class, e, > e.backtrace; end' & > [1] 2664 > $ echo $! > 2664 > $ kill -INT $! > $ Interrupt > Interrupt > ["-e:1:in `sleep'", "-e:1:in `
'"] > [1]+ Done ruby19 -e 'begin; sleep 60; rescue > Exception => e; p e.class, e, e.backtrace; end' > That indeed looks very clever. But I note that if the script is terminated I get "SignalException" and not "Terminated". Also, I note that backtrace is a list, and I was wondering what method Ruby normally uses to reformat and pretty print that (Ruby is not simply printing and indenting the lines). However, I fail to see how this exception handling should be integrated in practice with my code that currently relies on an at_exit call (line 84): http://code.google.com/p/biopieces/source/browse/trunk/code_ruby/Maasha/lib/biopieces.rb And just a reminder that I am trying to create super simplified scripts of this type: http://pastie.org/1013476 Cheers, Martin -- Posted via http://www.ruby-forum.com/.