1pthread_cancel(3C) Standard C Library Functions pthread_cancel(3C)
2
3
4
6 pthread_cancel - cancel execution of a thread
7
9 cc -mt [ flag... ] file... -lpthread [ library... ]
10 #include <pthread.h>
11
12 int pthread_cancel(pthread_t target_thread);
13
14
16 The pthread_cancel() function requests that target_thread be canceled.
17
18
19 By default, cancellation is deferred until target_thread reaches a can‐
20 cellation point. See cancellation(5).
21
22
23 Cancellation cleanup handlers for target_thread are called when the
24 cancellation is acted on. Upon return of the last cancellation cleanup
25 handler, the thread-specific data destructor functions are called for
26 target_thread. target_thread is terminated when the last destructor
27 function returns.
28
29
30 A thread acting on a cancellation request runs with all signals
31 blocked. All thread termination functions, including cancellation
32 cleanup handlers and thread-specific data destructor functions, are
33 called with all signals blocked.
34
35
36 The cancellation processing in target_thread runs asynchronously with
37 respect to the calling thread returning from pthread_cancel().
38
40 If successful, the pthread_cancel() function returns 0. Otherwise, an
41 error number is returned to indicate the error.
42
44 The pthread_cancel() function may fail if:
45
46 ESRCH No thread was found with an ID corresponding to that specified
47 by the given thread ID, target_thread.
48
49
51 See attributes(5) for descriptions of the following attributes:
52
53
54
55
56 ┌─────────────────────────────┬─────────────────────────────┐
57 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
58 ├─────────────────────────────┼─────────────────────────────┤
59 │Interface Stability │Committed │
60 ├─────────────────────────────┼─────────────────────────────┤
61 │MT-Level │MT-Safe │
62 ├─────────────────────────────┼─────────────────────────────┤
63 │Standard │See standards(5). │
64 └─────────────────────────────┴─────────────────────────────┘
65
67 pthread_cleanup_pop(3C), pthread_cleanup_push(3C),
68 pthread_cond_wait(3C), pthread_cond_timedwait(3C), pthread_exit(3C),
69 pthread_join(3C), pthread_setcancelstate(3C), pthread_setcancel‐
70 type(3C), pthread_testcancel(3C), setjmp(3C), attributes(5), cancella‐
71 tion(5), condition(5), standards(5)
72
74 See cancellation(5) for a discussion of cancellation concepts.
75
76
77
78SunOS 5.11 2 Nov 2007 pthread_cancel(3C)