PTHREAD_SETASYNCCANCEL(3P) SysV PTHREAD_SETASYNCCANCEL(3P)
NAME
pthread_setasynccancel - Enables or disables the asynchronous
cancelability of the calling thread
SYNOPSIS
#include <pthread.h>
int pthread_setasynccancel (state)
int state;
DESCRIPTION
The pthread_setasynccancel function sets the calling thread's
asynchronous cancelability state to that indicated by the state argument
and returns the previous asynchronous cancelability state.
The state argument specifies the new cancelability state; legal values
are:
CANCEL_ON Enables asynchronous cancellation
CANCEL_OFF
Disables asynchronous cancellation
By default, asynchronous cancelability is disabled, and general
cancelability is enabled (see the pthread_setcancel(3P) function), which
means that the thread can only be canceled at cancellation points.
If you enable both asynchronous cancelability and general cancelability,
the thread can be canceled at any time.
If you disable general cancelability, the thread cannot be canceled; the
state of asynchronous cancelability is ignored.
You should not enable asynchronous cancelability if the thread is
executing in a critical section, or is in another state that would be
difficult or impossible to recover from (for example, if the thread is
contending for a shared resource).
The C standard functions that you can safely call with asynchronous
cancelability enabled are the character handling functions, the
mathematical functions, the string handling functions, and the abs(3C)
function. The effect of calling any other C standard function with
asynchronous cancelability enabled is unspecified.
The character handling functions that you can safely call with
asynchronous cancelability enabled are:
isalnum isalpha iscntrl isdigit
isgraph islower isprint ispunct
isspace isupper isxdigit tolower
toupper
The mathematical functions that you can safely call with asynchronous
cancelability enabled are:
acos asin atan atan2
cos sin tan cosh
sinh tanh exp frexp
ldexp log log10 modf
pow sqrt ceil fabs
floor fmod
The string handling functions that you can safely call with asynchronous
cancelability enabled are:
memcpy memmove strcpy strncpy
strcat strncat memcmp strcmp
strcoll strncmp strxfrm memchr
strchr strcspn strpbrk strrchr
strspn strstr strtok memset
strerror strlen
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_setasynccancel 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_setcancel(3P)