diff --git a/ChangeLog b/ChangeLog index 3c1b9d7461..a81087e288 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sun Oct 31 22:24:14 2010 Nobuyoshi Nakada + + * eval.c (ruby_cleanup): free current VM and its objspace even + when exiting by SystemExit. + Sun Oct 31 22:10:56 2010 Nobuyoshi Nakada * compile.c (new_child_iseq): adjust argument types. diff --git a/eval.c b/eval.c index 25969217ca..bbf66b3152 100644 --- a/eval.c +++ b/eval.c @@ -162,6 +162,17 @@ ruby_cleanup(volatile int ex) POP_TAG(); rb_thread_stop_timer_thread(); +#if EXIT_SUCCESS != 0 || EXIT_FAILURE != 1 + switch (ex) { +#if EXIT_SUCCESS != 0 + case 0: ex = EXIT_SUCCESS; break; +#endif +#if EXIT_FAILURE != 1 + case 1: ex = EXIT_FAILURE; break; +#endif + } +#endif + state = 0; for (nerr = 0; nerr < numberof(errs); ++nerr) { VALUE err = errs[nerr]; @@ -172,31 +183,21 @@ ruby_cleanup(volatile int ex) if (TYPE(err) == T_NODE) continue; if (rb_obj_is_kind_of(err, rb_eSystemExit)) { - return sysexit_status(err); + ex = sysexit_status(err); + break; } else if (rb_obj_is_kind_of(err, rb_eSignal)) { VALUE sig = rb_iv_get(err, "signo"); state = NUM2INT(sig); break; } - else if (ex == 0) { - ex = 1; + else if (ex == EXIT_SUCCESS) { + ex = EXIT_FAILURE; } } ruby_vm_destruct(GET_VM()); if (state) ruby_default_signal(state); -#if EXIT_SUCCESS != 0 || EXIT_FAILURE != 1 - switch (ex) { -#if EXIT_SUCCESS != 0 - case 0: return EXIT_SUCCESS; -#endif -#if EXIT_FAILURE != 1 - case 1: return EXIT_FAILURE; -#endif - } -#endif - return ex; }