pthread_setasynccancel(3)
NAME
pthread_setasynccancel - Enables or disables the current thread’s asynchronous cancelability
SYNOPSIS
#include <pthread.h>
int pthread_setasynccancel( int state);
PARAMETERS
stateState of asynchronous cancelability set for the calling thread. On return, receives the prior state of asynchronous cancelability. Valid values are as follows:
CANCEL_ONAsynchronous cancelability is enabled.
CANCEL_OFFAsynchronous cancelability is disabled.
DESCRIPTION
The pthread_setasynccancel() routine enables or disables the current thread’s asynchronous cancelability and returns the previous asynchronous 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 CANCEL_ON and asynchronous cancelability 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 the pthread_testcancel() routine). If both general cancelability and asynchronous cancelability are set to CANCEL_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 is disabled by a previous call to this routine. Do not call threads routines 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, the previous state of asynchronous cancelability is returned. If the function fails, -1 is returned. Following are the possible return values and the possible corresponding values (if any) for errno:
| Return | Error | Description |
| CANCEL_ON | Asynchronous cancelability was on. | |
| CANCEL_OFF | Asynchronous cancelability was off. | |
| −1 | [EINVAL] | The specified state is not CANCEL_ON or CANCEL_OFF. |
RELATED INFORMATION
Functions: pthread_cancel(3), pthread_setcancel(3), pthread_testcancel(3).
Hewlett-Packard Company — OSF DCE 1.1/HP DCE 1.5