]> git.ipfire.org Git - thirdparty/man-pages.git/blame_incremental - 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
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
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.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
39Compile and link with \fI\-pthread\fP.
40.PP
41.in -4n
42Feature 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
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.PP
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"
71before the call.
72.PP
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.PP
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.PP
88This sequence of calls:
89.PP
90.in +4n
91.EX
92pthread_cleanup_push_defer_np(routine, arg);
93pthread_cleanup_pop_restore_np(execute);
94.EE
95.in
96.PP
97is 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
103int oldtype;
104
105pthread_cleanup_push(routine, arg);
106pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, &oldtype);
107\&...
108pthread_setcanceltype(oldtype, NULL);
109pthread_cleanup_pop(execute);
110.EE
111.in
112.\" SH VERSIONS
113.\" Available since glibc 2.0
114.SH CONFORMING TO
115These functions are nonstandard GNU extensions;
116hence 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)