## NAME

pthread_setcancelstate, pthread_setcanceltype - set cancelability state and type
pthread_testcancel - create a cancellation point

## SYNOPSIS

#include <pthread.h>

int pthread_setcancelstate(int state, int *oldstate);

int pthread_setcanceltype(int type, int *oldtype);

int pthread_setcanceltype_np(pthread_t thread, int type); - non POSIX function

void pthread_testcancel(void);

## DESCRIPTION

pthread_setcancelstate() atomically both sets the calling thread's cancelability state to the indicated state and return the previous cancelability state at the location referenced by oldstate. Legal values for state are PTHREAD_CANCEL_ENABLE and PTHREAD_CANCEL_DISABLE.

pthread_setcanceltype() atomically both sets the calling thread's cancelability type to the indicated type and return the previous cancelability type at the location referenced by oldtype. Legal values for type are PTHREAD_CANCEL_DEFERRED and PTHREAD_CANCEL_ASYNCHRONOUS.
pthread_setcanceltype_np() sets the specified by parameter thread thread's cancelability type to the indicated type. Legal values for type are PTHREAD_CANCEL_DEFERRED and PTHREAD_CANCEL_ASYNCHRONOUS.

The cancelability state and type of any newly created threads, including the Main() thread, will be PTHREAD_CANCEL_ENABLE and PTHREAD_CANCEL_DEFERRED respectively.

pthread_testcancel() creates a cancellation point in the calling thread. The pthread_testcancel() function has no effect if cancelability is disabled.

## RETURN VALUES

If successful, the pthread_setcancelstate() and pthread_setcanceltype() returns zero; otherwise, an error number will be returned to indicate the error.

## ERRORS

pthread_setcancelstate() function fails if:

EINVAL
  The specified state is not PTHREAD_CANCEL_ENABLE or PTHREAD_CANCEL_DISABLE.

pthread_setcanceltype() function fails if:

EINVAL
  The specified type is not PTHREAD_CANCEL_DEFERRED or PTHREAD_CANCEL_ASYNCHRONOUS.

pthread_setcanceltype_np() function fails if:

ESRCH
  The specified thread not found.

EINVAL
  The specified type is not PTHREAD_CANCEL_DEFERRED or PTHREAD_CANCEL_ASYNCHRONOUS.

## SEE ALSO

pthread_cancel()

#### Home page (Kernel)

## < Copyright Rowebots Research Inc. and Multiprocessor Toolsmiths Inc. 1987-2018 >