[Return to Bookshelf] [Contents] [Previous Section] [Next Section] [Index] [Help]


tis_setcancelstate

Sets the caller's cancelability state.

Syntax

tis_setcancelstate(
                   state,
                   oldstate );
 


Argument Data Type Access

state integer read oldstate integer write


C Binding

#include 

int tis_setcancelstate ( int state, int *oldstate );

Arguments

state
State of general cancelability to set for the calling thread. Valid state values are as follows:
oldstate
Previous cancelability state.

Description

This routine sets the caller's cancelability to state and returns the previous cancelability state to the location referenced by oldstate.

When cancelability state is set to PTHREAD_CANCEL_DISABLE, a cancel cannot be delivered to the thread, even if a cancelable routine is called or asynchronous cancelability type is enabled.

When a thread is created, the default general cancelability state is PTHREAD_CANCEL_ENABLE. When this routine is called prior to loading threads, the cancel state propagates to the initial thread in the executing program.

Possible Problems When Disabling Cancelability

The most important use of cancel calls 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), should be made cancelable.

When cancelability is disabled, no routine is cancelable. As a result, 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 particular region of code.

Return Values

On successful completion, this routine returns the previous state of general cancelability in 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.


Associated Routines

   tis_testcancel



[Return to Bookshelf] [Contents] [Previous Section] [Next Section] [Index] [Help]