]>
Commit | Line | Data |
---|---|---|
f06b4f5c MK |
1 | .\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk |
2 | .\" <mtk.manpages@gmail.com> | |
3 | .\" | |
93015253 | 4 | .\" %%%LICENSE_START(VERBATIM) |
f06b4f5c MK |
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. | |
4b72fb64 | 24 | .\" %%%LICENSE_END |
f06b4f5c | 25 | .\" |
8660ef9f | 26 | .TH PTHREAD_CLEANUP_PUSH_DEFER_NP 3 2014-05-28 "Linux" "Linux Programmer's Manual" |
f06b4f5c MK |
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> | |
dbfe9c70 | 33 | .PP |
f06b4f5c MK |
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 ); | |
6030f2d8 | 37 | .fi |
68e4db0a | 38 | .PP |
f06b4f5c | 39 | Compile and link with \fI\-pthread\fP. |
68e4db0a | 40 | .PP |
cff17c1b MK |
41 | .in -4n |
42 | Feature Test Macro Requirements for glibc (see | |
43 | .BR feature_test_macros (7)): | |
44 | .in | |
68e4db0a | 45 | .PP |
cff17c1b MK |
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 | |
f06b4f5c MK |
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. | |
847e0d88 | 59 | .PP |
f06b4f5c MK |
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" | |
b084fc29 | 71 | before the call. |
847e0d88 | 72 | .PP |
f06b4f5c MK |
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 (). | |
847e0d88 | 81 | .PP |
f06b4f5c MK |
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). | |
847e0d88 | 87 | .PP |
f06b4f5c | 88 | This sequence of calls: |
847e0d88 | 89 | .PP |
f06b4f5c MK |
90 | .in +4n |
91 | .nf | |
92 | pthread_cleanup_push_defer_np(routine, arg); | |
93 | pthread_cleanup_pop_restore_np(execute); | |
94 | .fi | |
95 | .in | |
847e0d88 | 96 | .PP |
f06b4f5c | 97 | is equivalent to (but shorter and more efficient than): |
847e0d88 | 98 | .PP |
310672d6 | 99 | .\" As far as I can see, LinuxThreads reverses the two substeps |
f06b4f5c MK |
100 | .\" in the push and pop below. |
101 | .in +4n | |
102 | .nf | |
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 | .fi | |
111 | .in | |
112 | .\" SH VERSIONS | |
113 | .\" Available since glibc 2.0 | |
114 | .SH CONFORMING TO | |
c8f2dd47 | 115 | These functions are nonstandard GNU extensions; |
d603cc27 | 116 | hence the suffix "_np" (nonportable) in the names. |
f06b4f5c MK |
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) |