Sets the current thread's cancelability state.
pthread_setcancelstate( state, oldstate );
Argument Data Type Accessstate integer read oldstate integer write
#includeint pthread_setcancelstate ( int state, int *oldstate );
When cancelability state is set to PTHREAD_CANCEL_DISABLE, a cancel cannot be delivered to the thread, even if a cancelable routine is called or asynchronous cancelability type is enabled.
When a thread is created, the default general cancelability state is PTHREAD_CANCEL_ENABLE.
Possible Problems When Disabling Cancelability
The most important use of cancel calls 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.
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 an integer value indicating the type of error. Possible return values are as follows:
Return Description 0 Successful completion. [EINVAL] The specified state is not PTHREAD_CANCEL_ENABLE or PTHREAD_CANCEL_DISABLE.
pthread_cancel pthread_setcanceltype pthread_testcancel