pthread_cancel

Cancels the execution of a thread.

Library:LibC
Classification:POSIX
Service:Threads

Syntax

  #include <pthread.h>
   
  int   pthread_cancel (
     pthread_t   thread);
  

Parameters

thread

(IN) Specifies the thread to cancel.

Return Values

If successful, returns 0; otherwise, returns a nonzero error code:

Decimal

Constant

Description

77

ERSCH

No thread was found that corresponded to the thread ID.

Remarks

The pthread_cancel function marks the thread for cancellation, and when the thread reaches a safe cancellation checkpoint, the thread is canceled and then destroyed.

When a thread is canceled depends upon the thread state and type. When the cancellation occurs, the cleanup routines for thread are called. When the last cleanup routine returns, the thread-specific data destructor functions are called for thread. When the last destructor function returns, thread is terminated.

See Also