diff options
Diffstat (limited to 'thread.c')
-rw-r--r-- | thread.c | 5 |
1 files changed, 5 insertions, 0 deletions
@@ -367,6 +367,7 @@ rb_thread_terminate_all(void) 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(); @@ -583,6 +584,10 @@ thread_s_new(int argc, VALUE *argv, VALUE klass) { rb_thread_t *th; VALUE thread = rb_thread_alloc(klass); + + if (GET_VM()->inhibit_thread_creation) + rb_raise(rb_eThreadError, "can't alloc thread"); + rb_obj_call_init(thread, argc, argv); GetThreadPtr(thread, th); if (!th->first_args) { |