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) {
  VALUE block;
  struct DATA *data;
  Data_Get_Struct(self, struct DATA, data);

  block = rb_block_proc();

  data->callback = block;
  pthread_create(&data->watchThread, NULL, &executer, data);

  return self;
}

I am using this because I want to provide ruby-code as a callback, which
will be executed, once the Thread receives a signal.

In general this is working fine, if the callback is something like this
ruby-code:

1 + 1

But, if the callbacks ruby-code looks like this:

puts "test"

than the main ruby process will stop responding, once the callback is
getting executed.
The thread is still running and able to react to signals and puts the
“test” everytime, the thread receives a message.

Can somebody maybe tell me, how to fix this?

Thanks a lot