There is a daemon which has two threads: th1, th2. th2 reads a socket using read(2)
.
If I kill the daemon with SIGTERM
, th1 catches and handles the signal (sets the termination flag), after that the daemon destructor get called, it calls pthread_kill(th2, SIGTERM)
. However, the second thread does not receive SIGTERM
, so it does not get killed (when the socket receives data and gets out from read()
, it finishes execution, as the termination flag has been set).
If I call pthread_kill(th2, SIGUSR2)
, and then pthread_kill(th2, SIGTERM)
, everything finishes correctly. Thus, it seems that UNIX doesn't allow sending identical signals consequently.
Does this behaviour depend on operating system? Can we ensure that the specified thread receives SIGTERM
from another thread?