Sets the cancellation type for the calling thread.
#include <pthread.h>
int pthread_setcanceltype (
int type,
int *oldtype);
(IN) Specifies the new cancellation type for the thread using one of the following flags:
(OUT) Points to the previous value for the cancellation type.
If successful, returns 0; otherwise returns a nonzero error code:
By default when a thread is created, the cancellation type is set to PTHREAD_CANCEL_DEFERRED.
When the cancel state is PTHREAD_CANCEL_ENABLE and the cancellation type is set to PTHREAD_CANCEL_DEFERRED, the thread can only receive a cancel at specific cancellation points, which include condition waits, thread joins, and calls to pthread_testcancel.
If the cancel state is PTHREAD_CANCEL_ENABLE and its cancellation type is THREAD_CANCEL_ASYNCHRONOUS, the thread can be canceled at any point in its execution.
IMPORTANT:If the asynchronous cancellation type is set, do not call any routine unless it is explicitly documented as safe to be called with an asynchronous cancellation type.