diff --git a/thread.c b/thread.c index 57a6962..3cf54ab 100644 --- a/thread.c +++ b/thread.c @@ -420,6 +420,12 @@ ruby_thread_init_stack(rb_thread_t *th) native_thread_init_stack(th); } +#ifdef USE_SIGALTSTACK +void rb_register_sigaltstack(rb_thread_t *th); +#else +# define rb_register_sigaltstack(th) for(;0;) +#endif + static int thread_start_func_2(rb_thread_t *th, VALUE *stack_start, VALUE *register_stack_start) { @@ -429,11 +435,15 @@ thread_start_func_2(rb_thread_t *th, VALUE *stack_start, VALUE *register_stack_s rb_thread_t *join_th; rb_thread_t *main_th; VALUE errinfo = Qnil; -# ifdef USE_SIGALTSTACK - void rb_register_sigaltstack(rb_thread_t *th); + + if (GET_VM()->inhibit_thread_creation) { + thread_debug("not starting thread due to interpreter shutdown: %p\n", (void *)th); + thread_cleanup_func(th, FALSE); + st_delete_wrap(th->vm->living_threads, th->self); + return 1; + } rb_register_sigaltstack(th); -# endif ruby_thread_set_native(th);