Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

pthread_setcancelstate(3) [osf1 man page]

pthread_setcancelstate(3)				     Library Functions Manual					 pthread_setcancelstate(3)

NAME
pthread_setcancelstate - Sets the calling thread's cancelability state. LIBRARY
DECthreads POSIX 1003.1c Library (libpthread.so) SYNOPSIS
#include <pthread.h> int pthread_setcancelstate( int state, int *oldstate); STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: IEEE Std 1003.1c-1995, POSIX System Application Program Interface PARAMETERS
State of general cancelability to set for the calling thread. The following are valid cancel state values: PTHREAD_CANCEL_ENABLE PTHREAD_CANCEL_DISABLE Previous cancelability state for the calling thread. DESCRIPTION
This routine sets the current 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, the 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 opera- tion performed by that thread. When disabling cancelability, be sure that no long waits can occur or that it is necessary for other rea- sons to defer cancelation requests around that particular region of code. RETURN VALUES
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: Successful completion. The specified state is not PTHREAD_CANCEL_ENABLE or PTHREAD_CANCEL_DISABLE. ERRORS
None RELATED INFORMATION
Functions: pthread_cancel(3), pthread_setcanceltype(3), pthread_testcancel(3) Manuals: Guide to DECthreads and Programmer's Guide delim off pthread_setcancelstate(3)

Check Out this Related Man Page

pthread_cancel(3)					     Library Functions Manual						 pthread_cancel(3)

NAME
pthread_cancel - Allows a thread to request a thread to terminate execution. LIBRARY
DECthreads POSIX 1003.1c Library (libpthread.so) SYNOPSIS
#include <pthread.h> int pthread_cancel( pthread_t thread); STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: IEEE Std 1003.1c-1995, POSIX System Application Program Interface PARAMETERS
Thread that receives a cancelation request. DESCRIPTION
This routine sends a cancelation request to the specified target thread. A cancelation request is a mechanism by which a calling thread requests the target thread to terminate as quickly as possible. Issuing a cancelation request does not guarantee that the target thread will receive or handle the request. When the cancelation request is acted on, all active cleanup handler routines for the target thread are called. When the last cleanup han- dler returns, the thread-specific data destructor routines are called for each thread-specific data key with a destructor and for which the target thread has a non-NULL value. Finally, the target thread is terminated. Note that cancelation of the target thread runs asynchronously with respect to the calling thread's returning from pthread_cancel(3). The target thread's cancelability state and type determine when or if the cancelation takes place, as follows: The target thread can delay can- celation during critical operations by setting its cancelability state to PTHREAD_CANCEL_DISABLE. Because of communication delays, the calling thread can only rely on the fact that a cancelation request will eventually become pending in the target thread (provided that the target thread does not terminate beforehand). The calling thread has no guarantee that a pending cancelation request will be delivered because delivery is controlled by the target thread. When a cancelation request is delivered to a thread, termination processing is similar to that for pthread_exit(3). For more information about thread termination, see the discussion of thread termination in pthread_create(3). This routine is preferred in implementing an Ada abort statement and any other language- or software-defined construct for requesting thread cancelation. The results of this routine are unpredictable, if the value specified in thread refers to a thread that does not currently exist. RETURN VALUES
If an error condition occurs, this routine returns an integer value indicating the type of error. Possible return values are as follows: Successful completion. The specified thread is invalid. The thread argument does not specify an existing thread. ERRORS
None RELATED INFORMATION
Functions: pthread_cleanup_pop(3), pthread_cleanup_push(3), pthread_create(3), pthread_exit(3), pthread_join(3), pthread_setcancelstate(3), pthread_setcanceltype(3), pthread_testcancel(3) Manuals: Guide to DECthreads and Programmer's Guide delim off pthread_cancel(3)

Featured Tech Videos