From 1a5f1a8c6966a973b26b85cb6e1e65ad0c5a5ed1 Mon Sep 17 00:00:00 2001 From: nobu Date: Thu, 10 Jul 2008 03:10:00 +0000 Subject: [PATCH] * vm_core.h (rb_thread_t), vm.c (rb_thread_mark), process.c (rb_last_status_get, rb_last_status_set, rb_last_status_clear): moved last_status from rb_vm_t. [ruby-dev:35414] * vm.c (th_init2): initialize last_status with nil. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17985 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 8 ++++++++ KNOWNBUGS.rb | 6 ------ bootstraptest/test_thread.rb | 6 ++++++ process.c | 13 ++++++------- vm.c | 3 ++- vm_core.h | 2 +- 6 files changed, 23 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index a3497c3822..17fc025d99 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Thu Jul 10 12:09:58 2008 Nobuyoshi Nakada + + * vm_core.h (rb_thread_t), vm.c (rb_thread_mark), process.c + (rb_last_status_get, rb_last_status_set, rb_last_status_clear): + moved last_status from rb_vm_t. [ruby-dev:35414] + + * vm.c (th_init2): initialize last_status with nil. + Thu Jul 10 12:09:21 2008 Nobuyoshi Nakada * thread.c (rb_thread_wait_for): wait until timed out only when diff --git a/KNOWNBUGS.rb b/KNOWNBUGS.rb index 36d757846c..39dc6a9b8b 100644 --- a/KNOWNBUGS.rb +++ b/KNOWNBUGS.rb @@ -2,9 +2,3 @@ # This test file concludes tests which point out known bugs. # So all tests will cause failure. # - -assert_equal 'ok', %q{ - t = Thread.new { system("false") } - t.join - $? ? :ng : :ok -} diff --git a/bootstraptest/test_thread.rb b/bootstraptest/test_thread.rb index d7ef671f73..72ae774b90 100644 --- a/bootstraptest/test_thread.rb +++ b/bootstraptest/test_thread.rb @@ -355,3 +355,9 @@ assert_equal 'ok', %q{ sleep 1; m.lock :ok } + +assert_equal 'ok', %q{ + t = Thread.new {`echo`} + t.join + $? ? :ng : :ok +} diff --git a/process.c b/process.c index f75175defd..6e757338c1 100644 --- a/process.c +++ b/process.c @@ -218,23 +218,22 @@ static VALUE rb_cProcessStatus; VALUE rb_last_status_get(void) { - return GET_VM()->last_status; + return GET_THREAD()->last_status; } void rb_last_status_set(int status, rb_pid_t pid) { - rb_vm_t *vm = GET_VM(); - vm->last_status = rb_obj_alloc(rb_cProcessStatus); - rb_iv_set(vm->last_status, "status", INT2FIX(status)); - rb_iv_set(vm->last_status, "pid", PIDT2NUM(pid)); + rb_thread_t *th = GET_THREAD(); + th->last_status = rb_obj_alloc(rb_cProcessStatus); + rb_iv_set(th->last_status, "status", INT2FIX(status)); + rb_iv_set(th->last_status, "pid", PIDT2NUM(pid)); } static void rb_last_status_clear(void) { - rb_vm_t *vm = GET_VM(); - vm->last_status = Qnil; + GET_THREAD()->last_status = Qnil; } /* diff --git a/vm.c b/vm.c index a6c62d69e9..6379bdfd89 100644 --- a/vm.c +++ b/vm.c @@ -1391,7 +1391,6 @@ rb_vm_mark(void *ptr) } RUBY_MARK_UNLESS_NULL(vm->thgroup_default); RUBY_MARK_UNLESS_NULL(vm->mark_object_ary); - RUBY_MARK_UNLESS_NULL(vm->last_status); RUBY_MARK_UNLESS_NULL(vm->load_path); RUBY_MARK_UNLESS_NULL(vm->loaded_features); RUBY_MARK_UNLESS_NULL(vm->top_self); @@ -1547,6 +1546,7 @@ rb_thread_mark(void *ptr) RUBY_MARK_UNLESS_NULL(th->fiber); RUBY_MARK_UNLESS_NULL(th->root_fiber); RUBY_MARK_UNLESS_NULL(th->stat_insn_usage); + RUBY_MARK_UNLESS_NULL(th->last_status); RUBY_MARK_UNLESS_NULL(th->locking_mutex); @@ -1595,6 +1595,7 @@ th_init2(rb_thread_t *th, VALUE self) th->status = THREAD_RUNNABLE; th->errinfo = Qnil; + th->last_status = Qnil; #if USE_VALUE_CACHE th->value_cache_ptr = &th->value_cache[0]; diff --git a/vm_core.h b/vm_core.h index f605445604..48fde8d8d9 100644 --- a/vm_core.h +++ b/vm_core.h @@ -305,7 +305,6 @@ struct rb_vm_struct st_table *living_threads; VALUE thgroup_default; - VALUE last_status; /* $? */ int running; int thread_abort_on_exception; @@ -408,6 +407,7 @@ struct rb_thread_struct rb_control_frame_t *cfp; int safe_level; int raised_flag; + VALUE last_status; /* $? */ /* passing state */ int state;