]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/pthread_cleanup_push_defer_np.3
fanotify_init.2, fanotify.7: Document FAN_REPORT_TID
[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.\"
4b8c67d9 26.TH PTHREAD_CLEANUP_PUSH_DEFER_NP 3 2017-09-15 "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>
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 39Compile and link with \fI\-pthread\fP.
68e4db0a 40.PP
cff17c1b
MK
41.in -4n
42Feature 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
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.
847e0d88 59.PP
f06b4f5c
MK
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.
847e0d88 72.PP
f06b4f5c
MK
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 ().
847e0d88 81.PP
f06b4f5c
MK
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).
847e0d88 87.PP
f06b4f5c 88This sequence of calls:
847e0d88 89.PP
f06b4f5c 90.in +4n
b8302363 91.EX
f06b4f5c
MK
92pthread_cleanup_push_defer_np(routine, arg);
93pthread_cleanup_pop_restore_np(execute);
b8302363 94.EE
f06b4f5c 95.in
847e0d88 96.PP
f06b4f5c 97is 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
b8302363 102.EX
f06b4f5c
MK
103int oldtype;
104
105pthread_cleanup_push(routine, arg);
106pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, &oldtype);
107\&...
108pthread_setcanceltype(oldtype, NULL);
109pthread_cleanup_pop(execute);
b8302363 110.EE
f06b4f5c
MK
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)