]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man7/nptl.7
dist.mk, All pages: .TH: Generate date at 'make dist'
[thirdparty/man-pages.git] / man7 / nptl.7
1 .\" Copyright (c) 2015 by Michael Kerrisk <mtk.manpages@gmail.com>
2 .\"
3 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
4 .\"
5 .\"
6 .TH NPTL 7 (date) "Linux man-pages (unreleased)"
7 .SH NAME
8 nptl \- Native POSIX Threads Library
9 .SH DESCRIPTION
10 NPTL (Native POSIX Threads Library)
11 is the GNU C library POSIX threads implementation that is used on modern
12 Linux systems.
13 .\"
14 .SS NPTL and signals
15 NPTL makes internal use of the first two real-time signals
16 (signal numbers 32 and 33).
17 One of these signals is used to support thread cancelation and POSIX timers
18 (see
19 .BR timer_create (2));
20 the other is used as part of a mechanism that ensures all threads in
21 a process always have the same UIDs and GIDs, as required by POSIX.
22 These signals cannot be used in applications.
23 .PP
24 To prevent accidental use of these signals in applications,
25 which might interfere with the operation of the NPTL implementation,
26 various glibc library functions and system call wrapper functions
27 attempt to hide these signals from applications,
28 as follows:
29 .IP * 3
30 .B SIGRTMIN
31 is defined with the value 34 (rather than 32).
32 .IP *
33 The
34 .BR sigwaitinfo (2),
35 .BR sigtimedwait (2),
36 and
37 .BR sigwait (3)
38 interfaces silently ignore requests to wait for these two signals
39 if they are specified in the signal set argument of these calls.
40 .IP *
41 The
42 .BR sigprocmask (2)
43 and
44 .BR pthread_sigmask (3)
45 interfaces silently ignore attempts to block these two signals.
46 .IP *
47 The
48 .BR sigaction (2),
49 .BR pthread_kill (3),
50 and
51 .BR pthread_sigqueue (3)
52 interfaces fail with the error
53 .B EINVAL
54 (indicating an invalid signal number) if these signals are specified.
55 .IP *
56 .BR sigfillset (3)
57 does not include these two signals when it creates a full signal set.
58 .\"
59 .SS NPTL and process credential changes
60 At the Linux kernel level,
61 credentials (user and group IDs) are a per-thread attribute.
62 However, POSIX requires that all of the POSIX threads in a process
63 have the same credentials.
64 To accommodate this requirement,
65 the NPTL implementation wraps all of the system calls that
66 change process credentials with functions that,
67 in addition to invoking the underlying system call,
68 arrange for all other threads in the process to also change their credentials.
69 .PP
70 The implementation of each of these system calls involves the use of
71 a real-time signal that is sent (using
72 .BR tgkill (2))
73 to each of the other threads that must change its credentials.
74 Before sending these signals, the thread that is changing credentials
75 saves the new credential(s) and records the system call being employed
76 in a global buffer.
77 A signal handler in the receiving thread(s) fetches this information and
78 then uses the same system call to change its credentials.
79 .PP
80 Wrapper functions employing this technique are provided for
81 .BR setgid (2),
82 .BR setuid (2),
83 .BR setegid (2),
84 .BR seteuid (2),
85 .BR setregid (2),
86 .BR setreuid (2),
87 .BR setresgid (2),
88 .BR setresuid (2),
89 and
90 .BR setgroups (2).
91 .\" FIXME .
92 .\" Maybe say something about vfork() not being serialized wrt set*id() APIs?
93 .\" https://sourceware.org/bugzilla/show_bug.cgi?id=14749
94 .SH STANDARDS
95 For details of the conformance of NPTL to the POSIX standard, see
96 .BR pthreads (7).
97 .SH NOTES
98 POSIX says
99 .\" See POSIX.1-2008 specification of pthread_mutexattr_init()
100 that any thread in any process with access to the memory
101 containing a process-shared
102 .RB ( PTHREAD_PROCESS_SHARED )
103 mutex can operate on that mutex.
104 However, on 64-bit x86 systems, the mutex definition for x86-64
105 is incompatible with the mutex definition for i386,
106 .\" See sysdeps/x86/bits/pthreadtypes.h
107 meaning that 32-bit and 64-bit binaries can't share mutexes on x86-64 systems.
108 .SH SEE ALSO
109 .BR credentials (7),
110 .BR pthreads (7),
111 .BR signal (7),
112 .BR standards (7)