|
Packit |
7cfc04 |
.\" Copyright (c) 2015 by Michael Kerrisk <mtk.manpages@gmail.com>
|
|
Packit |
7cfc04 |
.\"
|
|
Packit |
7cfc04 |
.\" %%%LICENSE_START(VERBATIM)
|
|
Packit |
7cfc04 |
.\" Permission is granted to make and distribute verbatim copies of this
|
|
Packit |
7cfc04 |
.\" manual provided the copyright notice and this permission notice are
|
|
Packit |
7cfc04 |
.\" preserved on all copies.
|
|
Packit |
7cfc04 |
.\"
|
|
Packit |
7cfc04 |
.\" Permission is granted to copy and distribute modified versions of this
|
|
Packit |
7cfc04 |
.\" manual under the conditions for verbatim copying, provided that the
|
|
Packit |
7cfc04 |
.\" entire resulting derived work is distributed under the terms of a
|
|
Packit |
7cfc04 |
.\" permission notice identical to this one.
|
|
Packit |
7cfc04 |
.\"
|
|
Packit |
7cfc04 |
.\" Since the Linux kernel and libraries are constantly changing, this
|
|
Packit |
7cfc04 |
.\" manual page may be incorrect or out-of-date. The author(s) assume no
|
|
Packit |
7cfc04 |
.\" responsibility for errors or omissions, or for damages resulting from
|
|
Packit |
7cfc04 |
.\" the use of the information contained herein. The author(s) may not
|
|
Packit |
7cfc04 |
.\" have taken the same level of care in the production of this manual,
|
|
Packit |
7cfc04 |
.\" which is licensed free of charge, as they might when working
|
|
Packit |
7cfc04 |
.\" professionally.
|
|
Packit |
7cfc04 |
.\"
|
|
Packit |
7cfc04 |
.\" Formatted or processed versions of this manual, if unaccompanied by
|
|
Packit |
7cfc04 |
.\" the source, must acknowledge the copyright and authors of this work.
|
|
Packit |
7cfc04 |
.\" %%%LICENSE_END
|
|
Packit |
7cfc04 |
.\"
|
|
Packit |
7cfc04 |
.\"
|
|
Packit |
7cfc04 |
.TH NPTL 7 2015-08-08 "Linux" "Linux Programmer's Manual"
|
|
Packit |
7cfc04 |
.SH NAME
|
|
Packit |
7cfc04 |
nptl \- Native POSIX Threads Library
|
|
Packit |
7cfc04 |
.SH DESCRIPTION
|
|
Packit |
7cfc04 |
NPTL (Native POSIX Threads Library)
|
|
Packit |
7cfc04 |
is the GNU C library POSIX threads implementation that is used on modern
|
|
Packit |
7cfc04 |
Linux systems.
|
|
Packit |
7cfc04 |
.\"
|
|
Packit |
7cfc04 |
.SS NPTL and signals
|
|
Packit |
7cfc04 |
NPTL makes internal use of the first two real-time signals
|
|
Packit |
7cfc04 |
(signal numbers 32 and 33).
|
|
Packit |
7cfc04 |
One of these signals is used to support thread cancellation and POSIX timers
|
|
Packit |
7cfc04 |
(see
|
|
Packit |
7cfc04 |
.BR timer_create (2));
|
|
Packit |
7cfc04 |
the other is used as part of a mechanism that ensures all threads in
|
|
Packit |
7cfc04 |
a process always have the same UIDs and GIDs, as required by POSIX.
|
|
Packit |
7cfc04 |
These signals cannot be used in applications.
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
To prevent accidental use of these signals in applications,
|
|
Packit |
7cfc04 |
which might interfere with the operation of the NPTL implementation,
|
|
Packit |
7cfc04 |
various glibc library functions and system call wrapper functions
|
|
Packit |
7cfc04 |
attempt to hide these signals from applications,
|
|
Packit |
7cfc04 |
as follows:
|
|
Packit |
7cfc04 |
.IP * 3
|
|
Packit |
7cfc04 |
.B SIGRTMIN
|
|
Packit |
7cfc04 |
is defined with the value 34 (rather than 32).
|
|
Packit |
7cfc04 |
.IP *
|
|
Packit |
7cfc04 |
The
|
|
Packit |
7cfc04 |
.BR sigwaitinfo (2),
|
|
Packit |
7cfc04 |
.BR sigtimedwait (2),
|
|
Packit |
7cfc04 |
and
|
|
Packit |
7cfc04 |
.BR sigwait (3)
|
|
Packit |
7cfc04 |
interfaces silently ignore requests to wait for these two signals
|
|
Packit |
7cfc04 |
if they are specified in the signal set argument of these calls.
|
|
Packit |
7cfc04 |
.IP *
|
|
Packit |
7cfc04 |
The
|
|
Packit |
7cfc04 |
.BR sigprocmask (2)
|
|
Packit |
7cfc04 |
and
|
|
Packit |
7cfc04 |
.BR pthread_sigmask (3)
|
|
Packit |
7cfc04 |
interfaces silently ignore attempts to block these two signals.
|
|
Packit |
7cfc04 |
.IP *
|
|
Packit |
7cfc04 |
The
|
|
Packit |
7cfc04 |
.BR sigaction (2),
|
|
Packit |
7cfc04 |
.BR pthread_kill (3),
|
|
Packit |
7cfc04 |
and
|
|
Packit |
7cfc04 |
.BR pthread_sigqueue (3)
|
|
Packit |
7cfc04 |
interfaces fail with the error
|
|
Packit |
7cfc04 |
.B EINVAL
|
|
Packit |
7cfc04 |
(indicating an invalid signal number) if these signals are specified.
|
|
Packit |
7cfc04 |
.IP *
|
|
Packit |
7cfc04 |
.BR sigfillset (3)
|
|
Packit |
7cfc04 |
does not include these two signals when it creates a full signal set.
|
|
Packit |
7cfc04 |
.\"
|
|
Packit |
7cfc04 |
.SS NPTL and process credential changes
|
|
Packit |
7cfc04 |
At the Linux kernel level,
|
|
Packit |
7cfc04 |
credentials (user and group IDs) are a per-thread attribute.
|
|
Packit |
7cfc04 |
However, POSIX requires that all of the POSIX threads in a process
|
|
Packit |
7cfc04 |
have the same credentials.
|
|
Packit |
7cfc04 |
To accommodate this requirement,
|
|
Packit |
7cfc04 |
the NPTL implementation wraps all of the system calls that
|
|
Packit |
7cfc04 |
change process credentials with functions that,
|
|
Packit |
7cfc04 |
in addition to invoking the underlying system call,
|
|
Packit |
7cfc04 |
arrange for all other threads in the process to also change their credentials.
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
The implementation of each of these system calls involves the use of
|
|
Packit |
7cfc04 |
a real-time signal that is sent (using
|
|
Packit |
7cfc04 |
.BR tgkill (2))
|
|
Packit |
7cfc04 |
to each of the other threads that must change its credentials.
|
|
Packit |
7cfc04 |
Before sending these signals, the thread that is changing credentials
|
|
Packit |
7cfc04 |
saves the new credential(s) and records the system call being employed
|
|
Packit |
7cfc04 |
in a global buffer.
|
|
Packit |
7cfc04 |
A signal handler in the receiving thread(s) fetches this information and
|
|
Packit |
7cfc04 |
then uses the same system call to change its credentials.
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
Wrapper functions employing this technique are provided for
|
|
Packit |
7cfc04 |
.BR setgid (2),
|
|
Packit |
7cfc04 |
.BR setuid (2),
|
|
Packit |
7cfc04 |
.BR setegid (2),
|
|
Packit |
7cfc04 |
.BR seteuid (2),
|
|
Packit |
7cfc04 |
.BR setregid (2),
|
|
Packit |
7cfc04 |
.BR setreuid (2),
|
|
Packit |
7cfc04 |
.BR setresgid (2),
|
|
Packit |
7cfc04 |
.BR setresuid (2),
|
|
Packit |
7cfc04 |
and
|
|
Packit |
7cfc04 |
.BR setgroups (2).
|
|
Packit |
7cfc04 |
.\" FIXME .
|
|
Packit |
7cfc04 |
.\" Maybe say something about vfork() not being serialized wrt set*id() APIs?
|
|
Packit |
7cfc04 |
.\" https://sourceware.org/bugzilla/show_bug.cgi?id=14749
|
|
Packit |
7cfc04 |
.SH CONFORMING TO
|
|
Packit |
7cfc04 |
For details of the conformance of NPTL to the POSIX standard, see
|
|
Packit |
7cfc04 |
.BR pthreads (7).
|
|
Packit |
7cfc04 |
.SH NOTES
|
|
Packit |
7cfc04 |
POSIX says
|
|
Packit |
7cfc04 |
.\" See POSIX.1-2008 specification of pthread_mutexattr_init()
|
|
Packit |
7cfc04 |
that any thread in any process with access to the memory
|
|
Packit |
7cfc04 |
containing a process-shared
|
|
Packit |
7cfc04 |
.RB ( PTHREAD_PROCESS_SHARED )
|
|
Packit |
7cfc04 |
mutex can operate on that mutex.
|
|
Packit |
7cfc04 |
However, on 64-bit x86 systems, the mutex definition for x86-64
|
|
Packit |
7cfc04 |
is incompatible with the mutex definition for i386,
|
|
Packit |
7cfc04 |
.\" See sysdeps/x86/bits/pthreadtypes.h
|
|
Packit |
7cfc04 |
meaning that 32-bit and 64-bit binaries can't share mutexes on x86-64 systems.
|
|
Packit |
7cfc04 |
.SH SEE ALSO
|
|
Packit |
7cfc04 |
.BR credentials (7),
|
|
Packit |
7cfc04 |
.BR pthreads (7),
|
|
Packit |
7cfc04 |
.BR signal (7),
|
|
Packit |
7cfc04 |
.BR standards (7)
|
|
Packit |
7cfc04 |
.SH COLOPHON
|
|
Packit |
7cfc04 |
This page is part of release 4.15 of the Linux
|
|
Packit |
7cfc04 |
.I man-pages
|
|
Packit |
7cfc04 |
project.
|
|
Packit |
7cfc04 |
A description of the project,
|
|
Packit |
7cfc04 |
information about reporting bugs,
|
|
Packit |
7cfc04 |
and the latest version of this page,
|
|
Packit |
7cfc04 |
can be found at
|
|
Packit |
7cfc04 |
\%https://www.kernel.org/doc/man\-pages/.
|