]> git.donarmstrong.com Git - biopieces.git/commitdiff
messing with exit in ruby - still
authormartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Tue, 22 Jun 2010 14:49:53 +0000 (14:49 +0000)
committermartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Tue, 22 Jun 2010 14:49:53 +0000 (14:49 +0000)
git-svn-id: http://biopieces.googlecode.com/svn/trunk@994 74ccb610-7750-0410-82ae-013aeee3265d

code_ruby/Maasha/lib/biopieces.rb

index 42391dcf90ad3cfc7312d12c56ab342876e5a83f..46fb26b737f123364f44a025b4208b8fd82f9383 100644 (file)
@@ -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