PTHREAD_SETCANCEL(3P) SysV PTHREAD_SETCANCEL(3P)
NAME
pthread_setcancel - Enables or disables the general cancelability of the
calling thread
SYNOPSIS
#include <pthread.h>
int pthread_setcancel (state)
int state;
DESCRIPTION
The pthread_setcancel function sets the calling thread's general
cancelability to that indicated by the state argument and returns the
previous cancelability state.
The state argument specifies the new cancelability state; legal values
are:
CANCEL_ON Enables general cancellation
CANCEL_OFF
Disables general cancellation
By default, general cancelability is enabled and asynchronous
cancelability (see the pthread_setasynccancel(3P) function) is
disabled, which means that the thread can only be canceled at
cancellation points. Cancellation points include the following:
+ While waiting on a condition variable (within a call to the
pthread_cond_wait(3P) or pthread_cond_timedwait(3P) function)
+ While waiting for the termination of another thread (within a
call to the pthread_join(3P) function)
+ Where the pthread_testcancel(3P) function has been called
+ Where the pthread_setcancel function has been called with the
argument CANCEL_ON
If the general cancelability of the target thread has been disabled,
the termination of the thread is held pending until general
cancelability is reenabled. If general cancelability is enabled and
asynchronous cancelability is enabled, the termination of the target
thread begins immediately. If general cancelability is enabled and
asynchronous cancelability is disabled, termination is held pending
until the next cancellation point.
NOTES
This interface is based on draft 4 of the IEEE P1003.4a standard, and
will be changed to conform to the final version.
DIAGNOSTICS
Upon successful completion, the previous value of the cancelability state
is returned. Otherwise, -1 is returned and errno is set to indicate the
error.
ERRORS
If the pthread_setcancel function fails, errno may be set to the
following value:
[EINVAL] The specified state is not CANCEL_ON or CANCEL_OFF.
SEE ALSO
pthread_cancel(3P), pthread_setasynccancel(3P)