1PTHREAD_CLEANUP_PUSH_DEFER_NLPi(n3u)x Programmer's MPaTnHuRaElAD_CLEANUP_PUSH_DEFER_NP(3)
2
3
4

NAME

6       pthread_cleanup_push_defer_np,  pthread_cleanup_pop_restore_np  -  push
7       and pop thread cancellation clean-up handlers while saving  cancelabil‐
8       ity type
9

SYNOPSIS

11       #include <pthread.h>
12
13       void pthread_cleanup_push_defer_np(void (*routine)(void *),
14                                          void *arg);
15       void pthread_cleanup_pop_restore_np(int execute);
16
17       Compile and link with -pthread.
18
19   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
20
21       pthread_cleanup_push_defer_np(), pthread_cleanup_pop_defer_np():
22           _GNU_SOURCE
23

DESCRIPTION

25       These   functions   are   the   same   as  pthread_cleanup_push(3)  and
26       pthread_cleanup_pop(3), except for the differences noted on this page.
27
28       Like  pthread_cleanup_push(3),  pthread_cleanup_push_defer_np()  pushes
29       routine  onto the thread's stack of cancellation clean-up handlers.  In
30       addition, it also saves the thread's current  cancelability  type,  and
31       sets  the  cancelability  type  to  "deferred"  (see pthread_setcancel‐
32       type(3)); this ensures that cancellation clean-up will  occur  even  if
33       the thread's cancelability type was "asynchronous" before the call.
34
35       Like  pthread_cleanup_pop(3), pthread_cleanup_pop_restore_np() pops the
36       top-most clean-up handler  from  the  thread's  stack  of  cancellation
37       clean-up handlers.  In addition, it restores the thread's cancelability
38       type   to    its    value    at    the    time    of    the    matching
39       pthread_cleanup_push_defer_np().
40
41       The  caller must ensure that calls to these functions are paired within
42       the same function, and  at  the  same  lexical  nesting  level.   Other
43       restrictions apply, as described in pthread_cleanup_push(3).
44
45       This sequence of calls:
46
47           pthread_cleanup_push_defer_np(routine, arg);
48           pthread_cleanup_pop_restore_np(execute);
49
50       is equivalent to (but shorter and more efficient than):
51
52           int oldtype;
53
54           pthread_cleanup_push(routine, arg);
55           pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, &oldtype);
56           ...
57           pthread_setcanceltype(oldtype, NULL);
58           pthread_cleanup_pop(execute);
59

CONFORMING TO

61       These  functions are nonstandard GNU extensions; hence the suffix "_np"
62       (nonportable) in the names.
63

SEE ALSO

65       pthread_cancel(3), pthread_cleanup_push(3),  pthread_setcancelstate(3),
66       pthread_testcancel(3), pthreads(7)
67

COLOPHON

69       This  page  is  part of release 4.15 of the Linux man-pages project.  A
70       description of the project, information about reporting bugs,  and  the
71       latest     version     of     this    page,    can    be    found    at
72       https://www.kernel.org/doc/man-pages/.
73
74
75
76Linux                             2017-09-15  PTHREAD_CLEANUP_PUSH_DEFER_NP(3)
Impressum