Enables or disables the current thread's general cancelability.
int pthread_setcancel( state );
Argument Data Type Accessstate integer read
int pthread_setcancel ( int state);
Value DescriptionCANCEL_ON Asynchronous cancelability is enabled. CANCEL_OFF Asynchronous cancelability is disabled.
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 a thread is created, the default general cancelability state is CANCEL_ON.
Possible Dangers of Disabling Cancelability
The most important use of cancels is to ensure that indefinite wait operations are terminated. For example, a thread waiting on some network connection, which may take days to respond (or may never respond), should be made cancelable.
However, when cancelability is disabled, no routine is cancelable. As a result, the user is unable to cancel the operation.
When disabling cancelability, be sure that no long waits can occur or that it is necessary for other reasons to defer cancels around that particular region of code.
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 DescriptionCANCEL_ON Successful completion. CANCEL_ Successful completion. OFF -1 [EINVAL] The specified state is not CANCEL_ON or CANCEL_OFF.