1PTHREAD_CLEANUP_PUSH_DEFER_NLPi(n3u)x Programmer's MPaTnHuRaElAD_CLEANUP_PUSH_DEFER_NP(3)
2
3
4
6 pthread_cleanup_push_defer_np, pthread_cleanup_pop_restore_np - push
7 and pop thread cancellation clean-up handlers while saving cancelabil‐
8 ity type
9
11 #include <pthread.h>
12
13 void pthread_cleanup_push_defer_np(void (*routine)(void *), void *arg);
14 void pthread_cleanup_pop_restore_np(int execute);
15
16 Compile and link with -pthread.
17
18 Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
19
20 pthread_cleanup_push_defer_np(), pthread_cleanup_pop_defer_np():
21 _GNU_SOURCE
22
24 These functions are the same as pthread_cleanup_push(3) and
25 pthread_cleanup_pop(3), except for the differences noted on this page.
26
27 Like pthread_cleanup_push(3), pthread_cleanup_push_defer_np() pushes
28 routine onto the thread's stack of cancellation clean-up handlers. In
29 addition, it also saves the thread's current cancelability type, and
30 sets the cancelability type to "deferred" (see pthread_setcancel‐
31 type(3)); this ensures that cancellation clean-up will occur even if
32 the thread's cancelability type was "asynchronous" before the call.
33
34 Like pthread_cleanup_pop(3), pthread_cleanup_pop_restore_np() pops the
35 top-most clean-up handler from the thread's stack of cancellation
36 clean-up handlers. In addition, it restores the thread's cancelability
37 type to its value at the time of the matching pthread_cleanup_push_de‐
38 fer_np().
39
40 The caller must ensure that calls to these functions are paired within
41 the same function, and at the same lexical nesting level. Other re‐
42 strictions apply, as described in pthread_cleanup_push(3).
43
44 This sequence of calls:
45
46 pthread_cleanup_push_defer_np(routine, arg);
47 pthread_cleanup_pop_restore_np(execute);
48
49 is equivalent to (but shorter and more efficient than):
50
51 int oldtype;
52
53 pthread_cleanup_push(routine, arg);
54 pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, &oldtype);
55 ...
56 pthread_setcanceltype(oldtype, NULL);
57 pthread_cleanup_pop(execute);
58
60 These functions are nonstandard GNU extensions; hence the suffix "_np"
61 (nonportable) in the names.
62
64 pthread_cancel(3), pthread_cleanup_push(3), pthread_setcancelstate(3),
65 pthread_testcancel(3), pthreads(7)
66
68 This page is part of release 5.12 of the Linux man-pages project. A
69 description of the project, information about reporting bugs, and the
70 latest version of this page, can be found at
71 https://www.kernel.org/doc/man-pages/.
72
73
74
75Linux 2021-03-22 PTHREAD_CLEANUP_PUSH_DEFER_NP(3)