pthreadsetcancelstate
pthread_setcancelstate is a POSIX Threads (pthreads) function that sets the cancelability state of the calling thread. It controls whether the thread can be canceled by cancellation requests. The function is declared as int pthread_setcancelstate(int state, int oldstate); and requires inclusion of pthread.h. The state argument must be either PTHREAD_CANCEL_ENABLE or PTHREAD_CANCEL_DISABLE. If oldstate is non-null, the function stores the thread’s previous cancelability state there.
When the state is PTHREAD_CANCEL_ENABLE, the thread may be canceled by a pending cancellation request. If a
Cancellation behavior is determined in part by pthread_setcanceltype, which selects between DEFERRED and ASYNCHRONOUS cancellation. The