VMS Help
POSIX Threads, PTHREAD routines, pthread_setcancelstate
*Conan The Librarian (sorry for the slow response - running on an old VAX)
|
|
Sets the calling thread's cancelability state.
#include <pthread.h>
int
pthread_setcancelstate (
int state,
int *oldstate );
state
State of general cancelability to set for the calling thread. The
following are valid cancel state values:
PTHREAD_CANCEL_ENABLE
PTHREAD_CANCEL_DISABLE
oldstate
Previous cancelability state for the calling thread.
This routine sets the calling thread's cancelability state and
returns the calling thread's previous cancelability state in
oldstate.
When 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 asynchronous cancelability type
is enabled.
When a thread is created, its default cancelability state is
PTHREAD_CANCEL_ENABLE.
Possible Problems When Disabling Cancelability
The most important use of thread cancelation is to ensure
that indefinite wait operations are terminated. For example, a
thread that waits on some network connection, which can possibly
take days to respond (or might never respond), should be made
cancelable.
When a thread's 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 or that it is
necessary for other reasons to defer cancelation requests around
that particular region of code.
On successful completion, this routine returns the calling
thread's previous cancelability state in the location specified
by the oldstate argument.
If an error condition occurs, this routine returns an integer
value indicating the type of error. Possible return values are as
follows:
Return Description
0 Successful completion.
[EINVAL] The specified state is not PTHREAD_CANCEL_ENABLE or
PTHREAD_CANCEL_DISABLE.
pthread_cancel()
pthread_setcanceltype()
pthread_testcancel()
[legal]
[privacy]
[GNU]
[policy]
[netiquette]
[sponsors]
[FAQ]
Polarhome, production since 1999.
Member of Polarhome portal.