]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/pthread_cleanup_push_defer_np.3
namespaces.7: ffix
[thirdparty/man-pages.git] / man3 / pthread_cleanup_push_defer_np.3
CommitLineData
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
28pthread_cleanup_push_defer_np, pthread_cleanup_pop_restore_np \- push and pop
29thread cancellation clean-up handlers while saving cancelability type
30.SH SYNOPSIS
31.nf
32.B #include <pthread.h>
33
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
f06b4f5c
MK
38.sp
39Compile and link with \fI\-pthread\fP.
cff17c1b
MK
40.sp
41.in -4n
42Feature Test Macro Requirements for glibc (see
43.BR feature_test_macros (7)):
44.in
45.sp
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
54These functions are the same as
55.BR pthread_cleanup_push (3)
56and
57.BR pthread_cleanup_pop (3),
58except for the differences noted on this page.
59
60Like
61.BR pthread_cleanup_push (3),
62.BR pthread_cleanup_push_defer_np ()
63pushes
64.I routine
65onto the thread's stack of cancellation clean-up handlers.
66In addition, it also saves the thread's current cancelability type,
67and sets the cancelability type to "deferred" (see
68.BR pthread_setcanceltype (3));
69this ensures that cancellation clean-up will occur
70even if the thread's cancelability type was "asynchronous"
b084fc29 71before the call.
f06b4f5c
MK
72
73Like
74.BR pthread_cleanup_pop (3),
75.BR pthread_cleanup_pop_restore_np ()
76pops the top-most clean-up handler from the thread's
77stack of cancellation clean-up handlers.
78In addition, it restores the thread's cancelability
79type to its value at the time of the matching
80.BR pthread_cleanup_push_defer_np ().
81
82The caller must ensure that calls to these
83functions are paired within the same function,
84and at the same lexical nesting level.
85Other restrictions apply, as described in
86.BR pthread_cleanup_push (3).
87
88This sequence of calls:
89
90.in +4n
91.nf
92pthread_cleanup_push_defer_np(routine, arg);
93pthread_cleanup_pop_restore_np(execute);
94.fi
95.in
96
97is equivalent to (but shorter and more efficient than):
98
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
103int oldtype;
104
105pthread_cleanup_push(routine, arg);
106pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, &oldtype);
107\&...
108pthread_setcanceltype(oldtype, NULL);
109pthread_cleanup_pop(execute);
110.fi
111.in
112.\" SH VERSIONS
113.\" Available since glibc 2.0
114.SH CONFORMING TO
c8f2dd47 115These functions are nonstandard GNU extensions;
d603cc27 116hence 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)