threads::shared: veto signal despatch if locked
This fixes RT #74868: Safe signals changes causing hangs with threads.
The basic issue is that due to changes in where safe signals can be
despatched, (including now on leaving scope), it's possible for a
perl-level signal handler to be called while PL_sharedsv_lock is held.
If the handler does locking or manipulation of shared vars, then deadlock
can occur.
A robust fix for this is to ensure that the signal handler isn't called
while we have the lock. This is done using the signal handler hook added
in the previous commit.