FWIW I wrote a library about 30 years ago so apps could be signal safe even when using 3rd party libs which were decidedly unsafe.
The basic idea is all signals (that can be) are blocked all the time, except when the app calls a handle_sigs() or similar routine from its main thread. That briefly unblocks all the signals, the actual signal catcher just sets bits in a mask, and then the registered handlers can be called in non-thread context. It's been used quite a bit in Junos over the past 25 years. If there's interest...
