Hi,

> At Sun, 27 May 2007 08:19:53 +0900,
> Johan Holmberg wrote in [ruby-core:11263]:
> > If an exception occurs in an at_exit block, the Ruby process
> > still exits with a zero exit status. This seems
> > wrong. Example code:
> > 
> >   $ ruby -e 'at_exit { raise "an error" }' ; echo $?
> >   -e:1: an error (RuntimeError)
> >           from -e:1
> >   0
> > 
> > All Ruby version I have tested work this way:
> 
> I'm not sure if this is a bug or a feature.

Sorry, exit code by SystemExit should not be altered.


Index: eval.c =================================================================== --- eval.c (revision 12393) +++ eval.c (working copy) @@ -193,4 +193,16 @@ ruby_cleanup(int ex) ruby_default_signal(NUM2INT(sig)); } + else if (ex == 0) { + ex = 1; + } + } + + switch (ex) { +#if EXIT_SUCCESS != 0 + case 0: return EXIT_SUCCESS; +#endif +#if EXIT_FAILURE != 1 + case 1: return EXIT_FAILURE; +#endif }
-- Nobu Nakada