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