]> git.donarmstrong.com Git - biopieces.git/commitdiff
ruby exit status battle part #12312423
authormartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Fri, 6 Aug 2010 09:33:05 +0000 (09:33 +0000)
committermartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Fri, 6 Aug 2010 09:33:05 +0000 (09:33 +0000)
git-svn-id: http://biopieces.googlecode.com/svn/trunk@1038 74ccb610-7750-0410-82ae-013aeee3265d

code_ruby/Maasha/lib/biopieces.rb

index f2776f2da4411c6ac98e47577cdf3aa37ef2e6a1..222e53b3b8772fe36f1482cd0371c8c79cd6e236 100644 (file)
@@ -602,36 +602,31 @@ def do_at_begin
   exit_status
 end
 
+exit_status = do_at_begin
+
 # Make sure that file streams are closed, tmpdir removed, and
 # exit status is written to log file.
-def do_at_exit(exit_status="OK-martin")
-  at_exit do
-    begin
-      @in.close  if @in.respond_to?  :close  # FIXME: This can never work
-      @out.close if @out.respond_to? :close  # FIXME: Same
-    rescue Exception => exception
-      $stderr.puts "Exception caught!"   # DEBUG
-      case exit_status
-      when 'INT'  then exit_status = 'INTERRUPTED'
-      when 'TERM' then exit_status = 'TERMINATED'
-      end
-      exit_status = "DIED" unless exit_status =~ /INT|TERM|QUIT/
-      $stderr.puts exit_status
-      $stderr.puts exception.backtrace
-    ensure
-      status = Status.new
-      FileUtils.remove_entry_secure(status.get_tmpdir)
-      status.log(exit_status)
-      status.delete
-      puts "DEBUG EXIT STATUS: #{exit_status}" # DEBUG
-    end
+at_exit do
+  begin
+    @in.close  if @in.respond_to?  :close  # FIXME: This can never work
+    @out.close if @out.respond_to? :close  # FIXME: Same
+  rescue Exception => exception
+    $stderr.puts "Exception caught!"   # DEBUG
+    case exit_status
+    when 'INT'  then exit_status = 'INTERRUPTED'
+    when 'TERM' then exit_status = 'TERMINATED'
+    end
+    exit_status = "DIED" unless exit_status =~ /INT|TERM|QUIT/
+    $stderr.puts exit_status
+    $stderr.puts exception.backtrace
+  ensure
+    status = Status.new
+    FileUtils.remove_entry_secure(status.get_tmpdir)
+    status.log(exit_status)
+    status.delete
+    puts "DEBUG EXIT STATUS: #{exit_status}" # DEBUG
   end
 end
 
-exit_status = do_at_begin
-
-END {
-  do_at_exit(exit_status)
-}
 
 __END__