Bug #12302
closed
at_exit status status is changed by raising/rescueing a exception in at_exit
Added by grosser (Michael Grosser) over 8 years ago.
Updated over 8 years ago.
Description
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
at_exit do |exception|
...
end
- Description updated (diff)
- Backport changed from 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN to 2.1: REQUIRED, 2.2: REQUIRED, 2.3: REQUIRED
- Status changed from Open to Closed
Applied in changeset r54681.
eval_jump.c: restore previous error info
- Project changed from Ruby master to Backport21
- Assignee set to ReiOdaira (Rei Odaira)
- Tracker changed from Bug to Backport
[removed spammer's comment and locked the account]
[removed spammer's comment and locked the account]
- Tracker changed from Backport to Bug
- Project changed from Backport21 to Ruby master
- ruby -v set to -
- Backport set to 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN
- Backport changed from 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN to 2.1: REQUIRED, 2.2: REQUIRED, 2.3: REQUIRED
- Backport changed from 2.1: REQUIRED, 2.2: REQUIRED, 2.3: REQUIRED to 2.1: REQUIRED, 2.2: REQUIRED, 2.3: DONE
ruby_2_3 r54718 merged revision(s) 54681.
- Backport changed from 2.1: REQUIRED, 2.2: REQUIRED, 2.3: DONE to 2.1: REQUIRED, 2.2: DONE, 2.3: DONE
ruby_2_2 r54769 merged revision(s) 54681.
Also available in: Atom
PDF
Like0
Like0Like0Like0Like0Like0Like0Like0Like0