From 2903ea4aeb7f9b73ec6d15819e811a4f0c715444 Mon Sep 17 00:00:00 2001 From: nobu Date: Thu, 9 Aug 2007 20:12:21 +0000 Subject: * 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 --- ChangeLog | 5 +++++ thread.c | 17 +++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/ChangeLog b/ChangeLog index 2ae927a7e6..6fae3b13e6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Fri Aug 10 05:12:19 2007 Nobuyoshi Nakada + + * thread.c (thread_start_func_2): let abort_on_exception work. + [ruby-core:11873] + Fri Aug 10 04:47:09 2007 Nobuyoshi Nakada * parse.y (internal_id_gen): internal ID must be bigger than 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; } -- cgit v1.2.3