I just found out that someone is calling - from a signal handler - a definitely not async-signal-safe function that I wrote.
So, now I\'m curious: how to circumvent this
If we can assume your application doesn't manually block signals using sigprocmask()
or pthread_sigmask()
, then this is pretty simple: get your current thread ID (tid
). Open /proc/tid/status
and get the values for SigBlk
and SigCgt
. AND
those two values. If the result of that AND
is non-zero, then that thread is currently running from inside a signal handler. I've tested this myself and it works.