Use pthread_kill(3THR) to send a signal to a thread.
Prototype: int pthread_kill(thread_t tid, int sig);
#include <pthread.h> #include <signal.h> int sig; pthread_t tid; int ret; ret = pthread_kill(tid, sig);
pthread_kill() sends the signal sig to the thread specified by tid. tid must be a thread within the same process as the calling thread. The sig argument must be from the list given in signal(5).
When sig is zero, error checking is performed but no signal is actually sent. This can be used to check the validity of tid.
Returns zero after completing successfully. Any other returned value indicates that an error occurred. When either of the following conditions occurs, pthread_kill() fails and returns the corresponding value.