>> I'm not sure why it is useful. If a lock is needed, then the lock should
>> be acquired in trap handler (and not supported yet). Detecting it is in
>> trap, and do what?
>
> How about allowing Mutex#lock to be recursive if (and only if) called
> inside trap?

I disagree. Recursive or not recursive depend on protected code and data
structure. Some case is safe and some another case is unsafe for recursive.

Then instead, I suggest to make RecursiveMutex class into stdlib. and
making a chance
rubyist choose a right mutex.