1pthread_setcancelstate(3C)Standard C Library Functionspthread_setcancelstate(3C)
2
3
4
6 pthread_setcancelstate - enable or disable cancellation
7
9 cc -mt [ flag... ] file... -lpthread [ library... ]
10 #include <pthread.h>
11
12 int pthread_setcancelstate(int state, int *oldstate);
13
14
16 The pthread_setcancelstate() function atomically sets the calling
17 thread's cancellation state to the specified state and if oldstate is
18 not NULL, stores the previous cancellation state in oldstate.
19
20
21 The state can be either of the following:
22
23 PTHREAD_CANCEL_ENABLE
24
25 This is the default. When cancellation is deferred (deferred can‐
26 cellation is also the default), cancellation occurs when the target
27 thread reaches a cancellation point and a cancel is pending. When
28 cancellation is asynchronous, receipt of a pthread_cancel(3C) call
29 causes immediate cancellation.
30
31
32 PTHREAD_CANCEL_DISABLE
33
34 When cancellation is deferred, all cancellation requests to the
35 target thread are held pending. When cancellation is asynchronous,
36 all cancellation requests to the target thread are held pending; as
37 soon as cancellation is re-enabled, pending cancellations are exe‐
38 cuted immediately.
39
40
41
42 See cancellation(5) for the definition of a cancellation point and a
43 discussion of cancellation concepts. See pthread_setcanceltype(3C) for
44 explanations of deferred and asynchronous cancellation.
45
47 Upon successful completion, pthread_setcancelstate(), returns 0. Other‐
48 wise, an error number is returned to indicate the error.
49
51 The pthread_setcancelstate() function will fail if:
52
53 EINVAL The specified state is not PTHREAD_CANCEL_ENABLE or
54 PTHREAD_CANCEL_DISABLE.
55
56
58 See attributes(5) for descriptions of the following attributes:
59
60
61
62
63 ┌─────────────────────────────┬─────────────────────────────┐
64 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
65 ├─────────────────────────────┼─────────────────────────────┤
66 │Interface Stability │Committed │
67 ├─────────────────────────────┼─────────────────────────────┤
68 │MT-Level │MT-Safe │
69 ├─────────────────────────────┼─────────────────────────────┤
70 │Standard │See standards(5). │
71 └─────────────────────────────┴─────────────────────────────┘
72
74 pthread_cancel(3C), pthread_cleanup_pop(3C), pthread_cleanup_push(3C),
75 pthread_exit(3C), pthread_join(3C), pthread_setcanceltype(3C),
76 pthread_testcancel(3C), setjmp(3C), attributes(5), cancellation(5),
77 condition(5), standards(5)
78
79
80
81SunOS 5.11 22 Jan 2008 pthread_setcancelstate(3C)