|PTHREAD_SETCANCELSTATE(3)||Linux Programmer's Manual||PTHREAD_SETCANCELSTATE(3)|
NAMEpthread_setcancelstate, pthread_setcanceltype - set cancelability state and type
int pthread_setcancelstate(int state, int *oldstate);
int pthread_setcanceltype(int type, int *oldtype);
Compile and link with -pthread.
DESCRIPTIONThe pthread_setcancelstate() sets the cancelability state of the calling thread to the value given in state. The previous cancelability state of the thread is returned in the buffer pointed to by oldstate. The state argument must have one of the following values:
- The thread is cancelable. This is the default cancelability state in all new threads, including the initial thread. The thread's cancelability type determines when a cancelable thread will respond to a cancellation request.
- The thread is not cancelable. If a cancellation request is received, it is blocked until cancelability is enabled.
The pthread_setcanceltype() sets the cancelability type of the calling thread to the value given in type. The previous cancelability type of the thread is returned in the buffer pointed to by oldtype. The type argument must have one of the following values:
- A cancellation request is deferred until the thread next calls a function that is a cancellation point (see pthreads(7)). This is the default cancelability type in all new threads, including the initial thread.
- The thread can be canceled at any time. (Typically, it will be canceled immediately upon receiving a cancellation request, but the system doesn't guarantee this.)
The set-and-get operation performed by each of these functions is atomic with respect to other threads in the process calling the same function.
RETURN VALUEOn success, these functions return 0; on error, they return a nonzero error number.
ERRORSThe pthread_setcancelstate() can fail with the following error:
- Invalid value for state.
The pthread_setcanceltype() can fail with the following error:
- Invalid value for type.
NOTESFor details of what happens when a thread is canceled, see pthread_cancel(3).
SEE ALSOpthread_cancel(3), pthread_cleanup_push(3), pthread_testcancel(3), pthreads(7)
COLOPHONThis page is part of release 3.53 of the Linux man-pages project. A description of the project, and information about reporting bugs, can be found at http://www.kernel.org/doc/man-pages/.