Q1: A safe signal with an asynchronous signal is the strongest reentrant concept. This requires very careful use of resources and is difficult to manage in a cross-platform application code.
Q2: Safe asynchronous signal implies thread safety. A thread safe means that you need to try calling the function twice, but from different threads; asynchronous signal security is stronger because two function calls can be on the same thread. This complicates the work because you cannot just wait until another function call releases its locks, the second call inside the signal handler should be able to interrupt the first, even if the shared resources are in an inconsistent state, and then restore things when they exit. In principle, it is not possible to use shared resources / state from a signal handler: always use a "trick with a self-recording" if you really do not know how the signal handlers work, and there is some unclear reason for writing crazy code.
Q3: Some people may use reentrant to keep in mind only thread safety. Unix signal handlers are the only place where something more powerful is needed, and this is a bit unclear because you should not try to do anything smart.
source share