From: martinahansen Date: Tue, 22 Jun 2010 14:49:53 +0000 (+0000) Subject: messing with exit in ruby - still X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=76028c43a0ae3c74f49e4052022c4ca995a1190e;p=biopieces.git messing with exit in ruby - still git-svn-id: http://biopieces.googlecode.com/svn/trunk@994 74ccb610-7750-0410-82ae-013aeee3265d --- diff --git a/code_ruby/Maasha/lib/biopieces.rb b/code_ruby/Maasha/lib/biopieces.rb index 42391dc..46fb26b 100644 --- a/code_ruby/Maasha/lib/biopieces.rb +++ b/code_ruby/Maasha/lib/biopieces.rb @@ -81,16 +81,35 @@ class Biopieces path end - at_exit do + def do_at_exit @in.close if @in.respond_to? :close @out.close if @out.respond_to? :close + exit_status = "OK" + + rescue SignalException => exception + if exception.class.to_s.upcase =~ /INT/ + exit_status = "INTERRUPTED" + elsif exception.to_s.upcase =~ /TERM/ + exit_status = "TERMINATED" + elsif exception.to_s.upcase =~ /QUIT/ + exit_status = "QUIT" + end + + rescue Exception => exception + exit_status = "DIED" + + $stderr.puts exception + $stderr.puts exception.backtrace + + ensure status = Status.new FileUtils.remove_entry_secure(status.get_tmpdir) - - status.log(@exit_status) + status.log(exit_status) status.delete end + + at_exit {do_at_exit} end