Open System Services System Calls Reference Manual (G06.25+, H06.03+)

pthread_cancel(2) OSS System Calls Reference Manual
NAME
pthread_cancel - Requests that a thread terminate execution
LIBRARY
G-series native OSS processes: /G/system/sysnn/zsptsrl
H-series OSS processes: /G/system/zdllnnn/zsptdll
SYNOPSIS
#include <spthread.h>
int pthread_cancel(
pthread_t thread );
PARAMETERS
thread species the thread that receives the cancelation request.
DESCRIPTION
This function sends a cancelation request to the specied 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-specic data destructor routines are
called for each thread-specic 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 threads returning from
pthread_cancel(). The target threads 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.
RETURN VALUES
If an error condition occurs, this function returns an integer value indicating the type of error.
Possible return values are:
0 Successful completion.
[ESRCH] The value of the thread parameter does not specify an existing thread.
538 Hewlett-Packard Company 527186-003