calling IO Operations from thread in ruby c extension will cause ruby to hang
问题 I have a problem with using threads in a C Extension to run ruby code async. I have the following C code: struct DATA { VALUE callback; pthread_t watchThread; void *ptr; }; void *executer(void *ptr) { struct DATA *data = (struct DATA *) ptr; char oldVal[20] = "1"; char newVal[20] = "1"; pthread_cleanup_push(&threadGarbageCollector, data); while(1) { if(triggerReceived) { rb_funcall(data->callback, rb_intern("call"), 0); } } pthread_cleanup_pop(1); return NULL; } VALUE spawn_thread(VALUE self)