summaryrefslogtreecommitdiff
path: root/thread.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-08-05 21:55:23 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-08-05 21:55:23 +0000
commit3af2559d17bbd5b77689440d2e54c905c6cd91aa (patch)
tree2c27fb204b013c2c93688da57b841236009114cb /thread.c
parentc97a8423911be84bf4de58cd5f7c8cafdc795273 (diff)
* thread.c (thread_start_func_2): propagates fatal error and system
exit to the main thread. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18381 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'thread.c')
-rw-r--r--thread.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/thread.c b/thread.c
index 1650b9b4ca..ffa3fce476 100644
--- a/thread.c
+++ b/thread.c
@@ -382,11 +382,25 @@ thread_start_func_2(rb_thread_t *th, VALUE *stack_start, VALUE *register_stack_s
});
}
else {
- if (th->safe_level < 4 &&
- (th->vm->thread_abort_on_exception ||
- th->abort_on_exception || RTEST(ruby_debug))) {
- errinfo = th->errinfo;
- if (NIL_P(errinfo)) errinfo = rb_errinfo();
+ errinfo = th->errinfo;
+ if (NIL_P(errinfo)) errinfo = rb_errinfo();
+ if (state == TAG_FATAL) {
+ /* fatal error within this thread, need to stop whole script */
+ }
+ else if (rb_obj_is_kind_of(errinfo, rb_eSystemExit)) {
+ if (th->safe_level >= 4) {
+ th->errinfo = rb_exc_new3(rb_eSecurityError,
+ rb_sprintf("Insecure exit at level %d", th->safe_level));
+ errinfo = Qnil;
+ }
+ }
+ else if (th->safe_level < 4 &&
+ (th->vm->thread_abort_on_exception ||
+ th->abort_on_exception || RTEST(ruby_debug))) {
+ /* exit on main_thread */
+ }
+ else {
+ errinfo = Qnil;
}
th->value = Qnil;
}