1pthread_cleanup_push_defer_nLpi(b3r)ary Functions Mapntuharlead_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 cancelation clean-up handlers while saving cancelability
8       type
9

LIBRARY

11       POSIX threads library (libpthread, -lpthread)
12

SYNOPSIS

14       #include <pthread.h>
15
16       void pthread_cleanup_push_defer_np(void (*routine)(void *), void *arg);
17       void pthread_cleanup_pop_restore_np(int execute);
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 cancelation 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 cancelation clean-up will occur even if the
33       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 cancelation clean-
37       up  handlers.  In addition, it restores the thread's cancelability type
38       to its value at  the  time  of  the  matching  pthread_cleanup_push_de‐
39       fer_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  re‐
43       strictions 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

STANDARDS

61       GNU; hence the suffix "_np" (nonportable) in the names.
62

HISTORY

64       glibc 2.0
65

SEE ALSO

67       pthread_cancel(3),  pthread_cleanup_push(3), pthread_setcancelstate(3),
68       pthread_testcancel(3), pthreads(7)
69
70
71
72Linux man-pages 6.04              2023-03-30  pthread_cleanup_push_defer_np(3)
Impressum