pthread_cancel - cancel execution of a thread
#include <pthread.h>
pthread_cancel() function requests that thread be canceled. The target thread's cancelability state and type determines when the cancellation takes effect. When the cancellation is acted on, the cancellation cleanup handlers for thread will be called. When the last cancellation cleanup handler returns, the thread-specific data destructor functions will be called for thread. When the last destructor function returns, thread will be terminated.
The cancellation processing in the target thread will run asynchronously with respect to the calling thread returning from pthread_cancel().
If successful, the pthread_cancel() returns zero; otherwise, an error number will be returned to indicate the error.
pthread_exit(), pthread_setcancelstate()