]>
Commit | Line | Data |
---|---|---|
1 | .\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk | |
2 | .\" <mtk.manpages@gmail.com> | |
3 | .\" | |
4 | .\" %%%LICENSE_START(VERBATIM) | |
5 | .\" Permission is granted to make and distribute verbatim copies of this | |
6 | .\" manual provided the copyright notice and this permission notice are | |
7 | .\" preserved on all copies. | |
8 | .\" | |
9 | .\" Permission is granted to copy and distribute modified versions of this | |
10 | .\" manual under the conditions for verbatim copying, provided that the | |
11 | .\" entire resulting derived work is distributed under the terms of a | |
12 | .\" permission notice identical to this one. | |
13 | .\" | |
14 | .\" Since the Linux kernel and libraries are constantly changing, this | |
15 | .\" manual page may be incorrect or out-of-date. The author(s) assume no | |
16 | .\" responsibility for errors or omissions, or for damages resulting from | |
17 | .\" the use of the information contained herein. The author(s) may not | |
18 | .\" have taken the same level of care in the production of this manual, | |
19 | .\" which is licensed free of charge, as they might when working | |
20 | .\" professionally. | |
21 | .\" | |
22 | .\" Formatted or processed versions of this manual, if unaccompanied by | |
23 | .\" the source, must acknowledge the copyright and authors of this work. | |
24 | .\" %%%LICENSE_END | |
25 | .\" | |
26 | .TH PTHREAD_CLEANUP_PUSH_DEFER_NP 3 2017-09-15 "Linux" "Linux Programmer's Manual" | |
27 | .SH NAME | |
28 | pthread_cleanup_push_defer_np, pthread_cleanup_pop_restore_np \- push and pop | |
29 | thread cancellation clean-up handlers while saving cancelability type | |
30 | .SH SYNOPSIS | |
31 | .nf | |
32 | .B #include <pthread.h> | |
33 | .PP | |
34 | .BI "void pthread_cleanup_push_defer_np(void (*" routine ")(void *)," | |
35 | .BI " void *" arg ); | |
36 | .BI "void pthread_cleanup_pop_restore_np(int " execute ); | |
37 | .fi | |
38 | .PP | |
39 | Compile and link with \fI\-pthread\fP. | |
40 | .PP | |
41 | .in -4n | |
42 | Feature Test Macro Requirements for glibc (see | |
43 | .BR feature_test_macros (7)): | |
44 | .in | |
45 | .PP | |
46 | .ad l | |
47 | .BR pthread_cleanup_push_defer_np (), | |
48 | .BR pthread_cleanup_pop_defer_np (): | |
49 | .RS 4 | |
50 | _GNU_SOURCE | |
51 | .RE | |
52 | .ad | |
53 | .SH DESCRIPTION | |
54 | These functions are the same as | |
55 | .BR pthread_cleanup_push (3) | |
56 | and | |
57 | .BR pthread_cleanup_pop (3), | |
58 | except for the differences noted on this page. | |
59 | .PP | |
60 | Like | |
61 | .BR pthread_cleanup_push (3), | |
62 | .BR pthread_cleanup_push_defer_np () | |
63 | pushes | |
64 | .I routine | |
65 | onto the thread's stack of cancellation clean-up handlers. | |
66 | In addition, it also saves the thread's current cancelability type, | |
67 | and sets the cancelability type to "deferred" (see | |
68 | .BR pthread_setcanceltype (3)); | |
69 | this ensures that cancellation clean-up will occur | |
70 | even if the thread's cancelability type was "asynchronous" | |
71 | before the call. | |
72 | .PP | |
73 | Like | |
74 | .BR pthread_cleanup_pop (3), | |
75 | .BR pthread_cleanup_pop_restore_np () | |
76 | pops the top-most clean-up handler from the thread's | |
77 | stack of cancellation clean-up handlers. | |
78 | In addition, it restores the thread's cancelability | |
79 | type to its value at the time of the matching | |
80 | .BR pthread_cleanup_push_defer_np (). | |
81 | .PP | |
82 | The caller must ensure that calls to these | |
83 | functions are paired within the same function, | |
84 | and at the same lexical nesting level. | |
85 | Other restrictions apply, as described in | |
86 | .BR pthread_cleanup_push (3). | |
87 | .PP | |
88 | This sequence of calls: | |
89 | .PP | |
90 | .in +4n | |
91 | .EX | |
92 | pthread_cleanup_push_defer_np(routine, arg); | |
93 | pthread_cleanup_pop_restore_np(execute); | |
94 | .EE | |
95 | .in | |
96 | .PP | |
97 | is equivalent to (but shorter and more efficient than): | |
98 | .PP | |
99 | .\" As far as I can see, LinuxThreads reverses the two substeps | |
100 | .\" in the push and pop below. | |
101 | .in +4n | |
102 | .EX | |
103 | int oldtype; | |
104 | ||
105 | pthread_cleanup_push(routine, arg); | |
106 | pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, &oldtype); | |
107 | \&... | |
108 | pthread_setcanceltype(oldtype, NULL); | |
109 | pthread_cleanup_pop(execute); | |
110 | .EE | |
111 | .in | |
112 | .\" SH VERSIONS | |
113 | .\" Available since glibc 2.0 | |
114 | .SH CONFORMING TO | |
115 | These functions are nonstandard GNU extensions; | |
116 | hence the suffix "_np" (nonportable) in the names. | |
117 | .SH SEE ALSO | |
118 | .BR pthread_cancel (3), | |
119 | .BR pthread_cleanup_push (3), | |
120 | .BR pthread_setcancelstate (3), | |
121 | .BR pthread_testcancel (3), | |
122 | .BR pthreads (7) |