pthread_setasynccancel(3thr)pthread_setasynccancel(3thr)Namepthread_setasynccancel - Enables or disables the current thread's asyn‐
chronous cancelability.
Syntax
#include <pthread.h>
int pthread_setasynccancel (state)
int state;
Arguments
state State of asynchronous cancelability to set for the calling
thread. Valid values are as follows:
Value Description
CANCEL_ON Asynchronous cancelability
is enabled.
CANCEL_OFF Asynchronous cancelability
is disabled.
Description
This routine enables or disables the current thread's asynchronous can‐
celability and returns the previous cancelability state.
When general cancelability is set to CANCEL_OFF, a cancel cannot be
delivered to the thread, even if a cancelable routine is called or
asynchronous cancelability is enabled. When general cancelability is
set to CANCEL_ON, cancelability depends on the state of the thread's
asynchronous cancelability. When general cancelability is set to CAN‐
CEL_ON and asynchronous cancelability is set to CANCEL_OFF, the thread
can only receive a cancel at specific cancelation points (for example,
condition waits, thread joins and calls to pthread_testcancel.) If both
general cancelability and asynchronous cancelability are set to CAN‐
CEL_ON, the thread can be canceled at any point in its execution.
When a thread is created, the default asynchronous cancelability state
is CANCEL_OFF.
If you call this routine to enable asynchronous cancels, call it in a
region of code where asynchronous delivery of cancels has been disabled
by a previous call to this routine. Threads routines should not be
called in regions of code where asynchronous delivery of cancels is
enabled. The previous state of asynchronous delivery can be restored
later by another call to this routine.
Return Values
On successful completion, this routine returns the previous state of
asynchronous cancelability.
If an error condition occurs, this routine returns -1 and sets errno to
the corresponding error value. Possible return values are as follows.
Return Error Description
0 Successful comple‐
tion.
-1 [EINVAL] The specified state
is not CANCEL_ON or
CANCEL_OFF.
pthread_setasynccancel(3thr)