Open System Services System Calls Reference Manual (G06.29+, H06.08+, J06.03+)
System Functions (n - p) pthread_cancel(2)
NAME
pthread_cancel - Requests that a thread terminate execution
LIBRARY
G-series native OSS processes: /G/system/sysnn/zsptsrl
32-bit H-series and J-series OSS processes that use the POSIX User Thread Model library:
/G/system/zdllnnn/zputdll
64-bit H-series and J-series OSS processes that use the POSIX User Thread Model library:
/G/system/zdllnnn/yputdll
H-series and J-series OSS processes that use the Standard POSIX Threads library:
/G/system/zdllnnn/zsptdll
SYNOPSIS
#include <pthread.h> | #include <spthread.h>
/* pthread.h is required to use POSIX User Thread Model library */
/* spthread.h is required to use Standard POSIX Threads library */
int pthread_cancel(
pthread_t thread);
PARAMETERS
thread Specifies the thread that receives the cancelation request.
DESCRIPTION
This function sends a cancelation request to the specified target thread. A cancelation request is
a mechanism by which a calling thread requests the target thread to terminate as quickly as possi-
ble. Issuing a cancelation request does not guarantee that the target thread receives or handles
the request.
When the cancelation request is acted on, all active cleanup-handler routines for the target thread
are called. When the last cleanup handler returns, the thread-specific data destructor routines are
called for each thread-specific data key with a destructor and for which the target thread has a
non-NULL value. Finally, the target thread is terminated, and a status of
PTHREAD_CANCELED is made available to any threads joining with the target thread.
Cancelation of the target thread runs asynchronously to the calling thread’s returning from
pthread_cancel(). The target thread’s cancelability state and type determine when or if the
cancelation takes place, as follows:
• The target thread can delay cancelation during critical operations by setting its cancela-
bility state to PTHREAD_CANCEL_DISABLE.
• Because of communication delays, the calling thread can rely only on the fact that a
cancelation request eventually becomes pending in the target thread (provided that the
target thread does not terminate beforehand).
• The calling thread has no guarantee that a pending cancelation request will be delivered,
because delivery is controlled by the target thread.
When a cancelation request is delivered to a thread, termination processing is similar to that for
pthread_exit(). For more information about thread termination, see the pthread_create(2)
reference page either online or in the Open System Services System Calls Reference Manual.
On systems running H06.21 or later H-series RVUs or J06.10 or later J-series RVUs, you can use
either the POSIX User Thread Model library or the Standard POSIX Threads library for threaded
applications.
To use this function in a threaded application that uses the POSIX User Thread Model library on
systems running H06.21 or later RVUs or J06.10 or later RVUs, you must perform all of the
527186-023 Hewlett-Packard Company 5−73