summaryrefslogtreecommitdiff
path: root/thread.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-08-09 20:12:21 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-08-09 20:12:21 +0000
commit2903ea4aeb7f9b73ec6d15819e811a4f0c715444 (patch)
treeac51c2785b943890fcb53de79e78fc08a277bd35 /thread.c
parentd3a1980b9632af97814240e21b29a3aeb3eb453a (diff)
* thread.c (thread_start_func_2): let abort_on_exception work.
[ruby-core:11873] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12913 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'thread.c')
-rw-r--r--thread.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/thread.c b/thread.c
index a70115fc63..f5c2773599 100644
--- a/thread.c
+++ b/thread.c
@@ -277,6 +277,9 @@ thread_cleanup_func(void *th_ptr)
native_thread_destroy(th);
}
+extern void ruby_error_print(void);
+static VALUE rb_thread_raise(int, VALUE *, rb_thread_t *);
+
static int
thread_start_func_2(rb_thread_t *th, VALUE *stack_start, VALUE *register_stack_start)
{
@@ -284,6 +287,8 @@ thread_start_func_2(rb_thread_t *th, VALUE *stack_start, VALUE *register_stack_s
VALUE args = th->first_args;
rb_proc_t *proc;
rb_thread_t *join_th;
+ VALUE errinfo = Qnil;
+
th->machine_stack_start = stack_start;
#ifdef __ia64
th->machine_register_stack_start = register_stack_start;
@@ -313,6 +318,12 @@ 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();
+ }
th->value = Qnil;
}
TH_POP_TAG();
@@ -331,6 +342,12 @@ thread_start_func_2(rb_thread_t *th, VALUE *stack_start, VALUE *register_stack_s
}
thread_cleanup_func(th);
native_mutex_unlock(&th->vm->global_interpreter_lock);
+
+ if (!NIL_P(errinfo) && th != th->vm->main_thread) {
+ /* exit on main_thread */
+ rb_thread_raise(1, &errinfo, th->vm->main_thread);
+ }
+
return 0;
}