From: rokki.winchester@...
Date: 2016-04-22T10:31:17+00:00
Subject: [ruby-core:75124] [Backport21 Backport#12302] at_exit status status is changed by raising/rescueing a exception in at_exit
Issue #12302 has been updated by karache deyong.
www.write-an-essay.org/
Wonderful article, a bunch of high-quality material. I���m going to point out to my girlftriend and ask them the things they think.
----------------------------------------
Backport #12302: at_exit status status is changed by raising/rescueing a exception in at_exit
https://bugs.ruby-lang.org/issues/12302#change-58256
* Author: Michael Grosser
* Status: Closed
* Priority: Normal
* Assignee: Rei Odaira
----------------------------------------
~~~ruby
at_exit do
puts "1 #{$!}"
end
at_exit do
puts "2 #{$!}"
raise 'x' rescue nil
end
at_exit do
puts "3 #{$!}"
exit 1
end
~~~
Nr 3 runs first and exits 1 ... Nr2 receives the correct exit status ... but using raise/rescue there overrides `$!` and Nr 1 thinks it is a clean exit ...
seems semi related to https://bugs.ruby-lang.org/issues/5218 ... ideally the `at_exit` block should restore the previous `$!` ... or give some other way of knowing the exit status like passing it to the block
~~~ruby
at_exit do |exception|
...
end
~~~
--
https://bugs.ruby-lang.org/
Unsubscribe: