pthread_setasynccancel(3) — Subroutines
Digital
NAME
pthread_setasynccancel − Enables or disables the current thread’s asynchronous cancellability.
SYNOPSIS
#include <pthread.h>
int pthread_setasynccancel(
int state );
PARAMETERS
stateState of asynchronous cancellability set for the calling thread. On return, receives the prior state of asynchronous cancellability. Valid values are as follows:
CANCEL_ONAsynchronous cancellability is enabled.
CANCEL_OFF
Asynchronous cancellability is disabled.
DESCRIPTION
This routine enables or disables the current thread’s asynchronous cancellability and returns the previous cancellability state to the state parameter.
When general cancellability is set to CANCEL_OFF, a cancel cannot be delivered to the thread, even if a cancellable routine is called or asynchronous cancellability is enabled. When general cancellability is set to CANCEL_ON, cancelability depends on the state of the thread’s asynchronous cancellability.
When general cancellability is set to CANCEL_ON and asynchronous cancellability is set to CANCEL_OFF, the thread can only receive a cancel at specific cancellation points (for example, condition waits, thread joins and calls to pthread_testcancel). If both general cancellability and asynchronous cancellability are set to CANCEL_ON, the thread can be cancelled at any point in its execution.
When a thread is created, the default asynchronous cancellability 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
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 completion. | |
| −1 | [EINVAL] | The specified state is not CANCEL_ON or CANCEL_OFF. |
RELATED INFORMATION
pthread_cancel(3), pthread_setcancel(3), pthread_testcancel(3)