NAME
pthread_setcancel - Enables or disables the current thread's
general cancelability
SYNOPSIS
#include <pthread.h>
int pthread_setcancel( int state );
PARAMETERS
state State of general cancelability set for the
calling thread. On return, receives the
prior state of general cancelability. Valid
values are as follows:
CANCEL_ON General cancelability is enabled.
CANCEL_OFF General cancelability is disabled.
DESCRIPTION
The pthread_setcancel() routine enables or disables the current thread's
general cancelability and returns the previous cancelability state to
the state parameter.
When general cancelability is set to CANCEL_OFF, a cancel cannot be
delivered to the thread, even if a cancelable routine is called or asyn-
chronous cancelability is enabled.
When a thread is created, the default general cancelability state is
CANCEL_ON.
POSSIBLE DANGERS OF DISABLING CANCELABILITY
The most important use of cancels is to ensure that indefinite wait
operations are terminated. For example, a thread waiting on some network
connection, which may take days to respond (or may never respond), is
normally made cancelable.
However, when cancelability is disabled, no routine is cancelable. Waits
must be completed normally before a cancel can be delivered. As a
result, the program stops working and the user is unable to cancel the
operation.
When disabling cancelability, be sure that no long waits can occur or
that it is necessary for other reasons to defer cancels around that par-
ticular region of code.
RETURN VALUES
If the function fails, errno may be set to one of the following values:
Return Error Description
___________________________________________________________
CANCEL_ON Asynchronous cancelability was on.
CANCEL_OFF Asynchronous cancelability was off.
-1 [EINVAL] The specified state is not CANCEL_ON
or CANCEL_OFF.
RELATED INFORMATION
FUNCTIONS: pthread_cancel
pthread_setasynccancel
pthread_testcancel