Bug #8501

exit code when an exception raised in at_exit hook

Added by Sam Phippen 10 months ago. Updated 10 months ago.

[ruby-core:55365]
Status:Closed
Priority:Normal
Assignee:-
Category:-
Target version:-
ruby -v:ruby 2.1.0dev (2013-06-08) [x86_64-darwin12.3.0] Backport:1.9.3: UNKNOWN, 2.0.0: UNKNOWN

Description

=begin
Actual Behaviour:

Running this file:

class MyStupidClass
def self.inspect
raise "LOOOOOL"
end
end

atexit { p $! }
at
exit { MyStupidClass.nope }

gives a 0 exit code and the following output:

foo.rb:8:in block in <main>': undefined methodnope' for #Class:0x007fe30b946740 (NoMethodError)
nil

Expected Behaviour:

A non-zero exit code, and $! populated in the at_exit hook.

Notes

Reproducible on ruby 2.1.0dev (2013-06-08), 2.0.0p0 and 1.9.3p392.

On 1.8.7 the output is:

foo.rb:8: undefined method `nope' for #Class:0x10de056b0 (NoMethodError)
from foo.rb:8
#

And the exit code is 1.
=end

Associated revisions

Revision 41205
Added by Nobuyoshi Nakada 10 months ago

eval_error.c: restore errinfo

  • evalerror.c (errorprint): restore errinfo for the case new excecption raised while printing the message. [Bug #8501]

History

#1 Updated by Nobuyoshi Nakada 10 months ago

  • Subject changed from Reentrant exceptions in at_exit hook to exit code when an exception raised in at_exit hook
  • Description updated (diff)

#2 Updated by Nobuyoshi Nakada 10 months ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r41205.
Sam, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


eval_error.c: restore errinfo

  • evalerror.c (errorprint): restore errinfo for the case new excecption raised while printing the message. [Bug #8501]

Also available in: Atom PDF