Allows a thread to request that it or another thread terminate execution.
pthread_cancel( thread );
Argument Data Type Accessthread opaque pthread_t read
int pthread_cancel ( pthread_t thread);
Because of communication delays, the calling thread can only rely on the fact that a cancel will eventually become pending in the designated thread (provided that the thread does not terminate beforehand). Furthermore, the calling thread has no guarantee that a pending cancel will be delivered because delivery is controlled by the designated thread.
Termination processing when a cancel is delivered to a thread is similar to pthread_exit. Outstanding cleanup routines are executed in the context of the target thread, and a status of -1 is made available to any threads joining with the target thread.
This routine is preferred in implementing an Ada abort statement and any other language- or software-defined construct for requesting thread cancellation.
The results of this routine are unpredictable if the value specified in thread refers to a thread that does not currently exist.
Return Error Description0 Successful completion. -1 [EINVAL] The specified thread is invalid. -1 [ESRCH] thread does not specify an existing thread.