Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ pthread_setcancel(3) — HP-UX 10.20

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

pthread_cancel(3)

pthread_setasynccancel(3)

pthread_testcancel(3)

pthread_setcancel(3)

NAME

pthread_setcancel - Enables or disables the current thread’s general cancelability

SYNOPSIS

#include <pthread.h> int pthread_setcancel( int state);

PARAMETERS

stateState of general cancelability set for the calling thread. On return, receives the prior state of general cancelability. Valid values are as follows:

CANCEL_ONGeneral cancelability is enabled. 

CANCEL_OFFGeneral cancelability is disabled. 

DESCRIPTION

The pthread_setcancel() routine enables or disables the current thread’s general cancelability and returns the previous general cancelability state. When general cancelability is set to CANCEL_OFF, a cancel cannot be delivered to the thread, even if a cancelable routine is called or asynchronous 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 particular region of code. 

RETURN VALUES

On successful completion, the previous state of general cancelability is returned. If the function fails, -1 is returned. Following are the possible return values and the possible corresponding values (if any) for errno:

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(3), pthread_setasynccancel(3), pthread_testcancel(3). 

Hewlett-Packard Company  —  OSF DCE 1.1/HP DCE 1.5

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026