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__