pthread_cancel - cancel execution of a thread
#include <pthread.h> int pthread_cancel(pthread_t thread);
The pthread_cancel() function requests that thread be canceled. The target threads cancelability state and type determines when the cancellation takes effect. When the cancellation is acted on, the cancellation cleanup handlers for thread are called. When the last cancellation cleanup handler returns, the thread-specific data destructor functions are called for thread. When the last destructor function returns, thread is terminated.
The cancellation processing in the target thread runs asynchronously with respect to the calling thread returning from pthread_cancel().
If successful, the pthread_cancel() function returns zero. Otherwise, an error number is returned to indicate the error.
The pthread_cancel() function may fail if:
- No thread could be found corresponding to that specified by the given thread ID.
The pthread_cancel() function will not return an error code of [EINTR].
pthread_exit(), pthread_join(), pthread_setcancelstate(), pthread_cond_wait(), pthread_cond_timedwait(), <pthread.h>.
Derived from the POSIX Threads Extension (1003.1c-1995)