summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-08-22 00:38:19 +0000
committershyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-08-22 00:38:19 +0000
commit4357f31d2525fabc5b3b2ef0fea7fdf0e519da56 (patch)
tree56390da116f5ad76371402113cdda910ada3adfb
parentae2d632c66fa59c3ab8c425f4743faf11fe5e4bc (diff)
* eval.c (ruby_cleanup): return EXIT_FAILURE if any exceptions occured
in at_exit blocks. [ruby-core:11263] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_6@13148 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--eval.c31
-rw-r--r--version.h2
3 files changed, 30 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index be7b4e7..dcf72fe 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Wed Aug 22 09:00:23 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * eval.c (ruby_cleanup): return EXIT_FAILURE if any exceptions occured
+ in at_exit blocks. [ruby-core:11263]
+
Wed Aug 22 08:52:02 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* variable.c (rb_path2class): get rid of dangling pointer caused by
diff --git a/eval.c b/eval.c
index 56a4bd1..d5e050b 100644
--- a/eval.c
+++ b/eval.c
@@ -1565,15 +1565,14 @@ ruby_cleanup(ex)
int ex;
{
int state;
- VALUE err;
volatile VALUE errs[2];
int nerr;
- errs[0] = ruby_errinfo;
+ errs[1] = ruby_errinfo;
ruby_safe_level = 0;
- Init_stack((void*)&state);
+ Init_stack((void *)&state);
ruby_finalize_0();
- errs[1] = ruby_errinfo;
+ errs[0] = ruby_errinfo;
PUSH_TAG(PROT_NONE);
PUSH_ITER(ITER_NOT);
if ((state = EXEC_TAG()) == 0) {
@@ -1584,13 +1583,16 @@ ruby_cleanup(ex)
ex = state;
}
POP_ITER();
- ruby_errinfo = errs[0];
+ ruby_errinfo = errs[1];
ex = error_handle(ex);
ruby_finalize_1();
POP_TAG();
- for (nerr = sizeof(errs) / sizeof(errs[0]); nerr;) {
- if (!(err = errs[--nerr])) continue;
+ for (nerr = 0; nerr < sizeof(errs) / sizeof(errs[0]); ++nerr) {
+ VALUE err = errs[nerr];
+
+ if (!RTEST(err)) continue;
+
if (rb_obj_is_kind_of(err, rb_eSystemExit)) {
return sysexit_status(err);
}
@@ -1598,7 +1600,22 @@ ruby_cleanup(ex)
VALUE sig = rb_iv_get(err, "signo");
ruby_default_signal(NUM2INT(sig));
}
+ else if (ex == 0) {
+ ex = 1;
+ }
+ }
+
+#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;
}
diff --git a/version.h b/version.h
index 64f269b..19e35f3 100644
--- a/version.h
+++ b/version.h
@@ -2,7 +2,7 @@
#define RUBY_RELEASE_DATE "2007-08-22"
#define RUBY_VERSION_CODE 186
#define RUBY_RELEASE_CODE 20070822
-#define RUBY_PATCHLEVEL 48
+#define RUBY_PATCHLEVEL 49
#define RUBY_VERSION_MAJOR 1
#define RUBY_VERSION_MINOR 8