diff --git a/thread.c b/thread.c index 10b73eb..3eb317e 100644 --- a/thread.c +++ b/thread.c @@ -366,18 +366,23 @@ rb_thread_terminate_all(void) rb_threadptr_unlock_all_locking_mutexes(th); thread_debug("rb_thread_terminate_all (main thread: %p)\n", (void *)th); - st_foreach(vm->living_threads, terminate_i, (st_data_t)th); vm->inhibit_thread_creation = 1; while (!rb_thread_alone()) { - PUSH_TAG(); - if (EXEC_TAG() == 0) { - rb_thread_schedule(); + if(GET_THREAD() == th) { + st_foreach(vm->living_threads, terminate_i, (st_data_t)th); + rb_thread_schedule(); } else { - /* ignore exception */ + PUSH_TAG(); + if (EXEC_TAG() == 0) { + rb_thread_schedule(); + } + else { + /* ignore exception */ + } + POP_TAG(); } - POP_TAG(); } }