Hi, according to the doc of rb_thread_blocking_region() (or
rb_thread_call_without_gvl() which is the same):


 *   If another thread interrupts this thread (Thread#kill, signal delivery,
 *   VM-shutdown request, and so on), `ubf()' is called (`ubf()' means
 *   "un-blocking function").  `ubf()' should interrupt `func()' execution.


Ok, in my case I'm coding a wrapper for UV (a C reactor library based
on EV when running on Linux). Let me explain a simple use case I'm
using for developming/testing purposes:


- In my script I trap SIGTERM signal:

    trap(:TERM) { puts "SIGTERM signal ignored" }

- I call to my C extension run() method which calls to:

  rb_thread_call_without_gvl(run_uv_without_gvl, NULL, my_ubf, NULL);

- run_uv_without_gvl() basically runs uv_run() function of UV library.
UV then blocks until events occur. In this experiment there are not
loaded events.

- So there is a single Ruby thread and now it's blocked in run_uv().
If there was another Ruby thread it would be running with the GVL, but
that's not the case.

- Then I send a SIGTERM signal to the process. UV ignores signals by
design, sure.

- So the problem is that: at this moment I see my_ubf() funcion called
!!! WHY? If I plan to trap/ignore SIGTERM signal, why is my_ubf()
ALWAYS called? why should I "interrupt my blocking function" (uv_run)
if I don't want since SIGTERM will be ignored in Ruby land?


I hope the description of the issue is clear, if not please ask to me,
I've spent days with this stuff and my conclusion is that the UBF()
function is always called.

Thanks a lot.








-- 
Iaki Baz Castillo
<ibc / aliax.net>