Open System Services System Calls Reference Manual (G06.25+, H06.03+)

pthread_setcancelstate(2) OSS System Calls Reference Manual
NAME
pthread_setcancelstate
- Sets the calling threads cancelability state
LIBRARY
G-series native OSS processes: /G/system/sysnn/zsptsrl
H-series OSS processes: /G/system/zdllnnn/zsptdll
SYNOPSIS
#include <spthread.h>
int pthread_setcancelstate(
int state,
int *oldstate );
PARAMETERS
state species the new cancelability state for the calling thread. Valid values are:
PTHREAD_CANCEL_ENABLE
PTHREAD_CANCEL_DISABLE
oldstate receives the previous cancelability state for the calling thread.
DESCRIPTION
This function sets the calling threads cancelability state to the value of the state parameter and
returns its previous cancelability state in the oldstate parameter.
When the cancelability state is set to PTHREAD_CANCEL_DISABLE, a cancelation request
cannot be delivered to the thread, even if a cancelable routine is called or an asynchronous
cancelability type is enabled.
When a thread is created, the default cancelability state is PTHREAD_CANCEL_ENABLE.
Possible Problems When Disabling Cancelability
The most important use of thread cancelation is to ensure that possibly indenite wait operations
are terminated. For example, a thread that waits on some network connection, which can possi-
bly take days to respond (or might never respond), should be made cancelable.
When a threads cancelability is disabled, no routine in that thread is cancelable. As a result, the
user is unable to cancel the operation performed by that thread. When disabling cancelability, be
sure that no long waits can occur and that no cancelation requests must be deferred around that
particular region of code for other reasons.
RETURN VALUES
On successful completion, this function returns the calling threads previous cancelability state in
the oldstate parameter.
If an error condition occurs, this function returns an integer value indicating the type of error.
Possible return values are:
0 Successful completion.
[EINVAL] The specied cancelability state is not PTHREAD_CANCEL_ENABLE or
PTHREAD_CANCEL_DISABLE.
RELATED INFORMATION
Functions: pthread_cancel(2), pthread_setcanceltype(2), pthread_testcancel(2).
590 Hewlett-Packard Company 527186-003