From: enh <enh@google.com>
To: "Michael Kerrisk (man-pages)" <mtk.manpages@gmail.com>
Cc: linux-man@vger.kernel.org
Subject: [PATCH] pthread_kill.3: Update to match POSIX.
Date: Tue, 12 Nov 2019 12:36:28 -0800 [thread overview]
Message-ID: <CAJgzZoojiRmTV_5sAXhqQciAKsQ_d+znT1OnxT0Rpa_-N_G5-Q@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 2279 bytes --]
POSIX removed ESRCH years ago.
In resolving http://austingroupbugs.net/view.php?id=1214 it was made
clear that callers can't rely on using signal 0 to test for the
continued existence of a thread. Update the man page to make it clearer
that this doesn't generally work (even if it sometimes seems to).
See also the long explanation of why this is the case (and how to fix
your code) here:
https://android.googlesource.com/platform/bionic/+/master/docs/status.md#invalid-handling-targetsdkversion-o
---
man3/pthread_kill.3 | 25 +++++++++----------------
1 file changed, 9 insertions(+), 16 deletions(-)
diff --git a/man3/pthread_kill.3 b/man3/pthread_kill.3
index e70e2669e..fb27afd24 100644
--- a/man3/pthread_kill.3
+++ b/man3/pthread_kill.3
@@ -56,10 +56,6 @@ to
a thread in the same process as the caller.
The signal is asynchronously directed to
.IR thread .
-.PP
-If
-.I sig
-is 0, then no signal is sent, but error checking is still performed.
.SH RETURN VALUE
On success,
.BR pthread_kill ()
@@ -93,26 +89,23 @@ this action will affect the whole process.
.PP
The glibc implementation of
.BR pthread_kill ()
-gives an error
-.RB ( EINVAL )
+gives the error
+.B EINVAL
on attempts to send either of the real-time signals
used internally by the NPTL threading implementation.
See
.BR nptl (7)
for details.
.PP
-POSIX.1-2008 recommends that if an implementation detects the use
-of a thread ID after the end of its lifetime,
+The glibc implementation of
.BR pthread_kill ()
-should return the error
-.BR ESRCH .
-The glibc implementation returns this error in the cases where
-an invalid thread ID can be detected.
-But note also that POSIX says that an attempt to use a thread ID whose
-lifetime has ended produces undefined behavior,
-and an attempt to use an invalid thread ID in a call to
+tries to give the error
+.B ESRCH
+on attempts to use an invalid thread ID, but this isn't always possible.
+An attempt to use an invalid thread ID in a call to
.BR pthread_kill ()
-can, for example, cause a segmentation fault.
+can, for example, cause a segmentation fault. Android is stricter, and will
+always abort when a pthread function is given an invalid thread ID.
.SH SEE ALSO
.BR kill (2),
.BR sigaction (2),
--
2.24.0.rc1.363.gb1bccd3e3d-goog
[-- Attachment #2: 0001-pthread_kill.3-Update-to-match-POSIX.patch --]
[-- Type: text/x-patch, Size: 2484 bytes --]
From 656249792d1782e2d8ca581663ee88b19181b084 Mon Sep 17 00:00:00 2001
From: Elliott Hughes <enh@google.com>
Date: Tue, 12 Nov 2019 12:19:52 -0800
Subject: [PATCH] pthread_kill.3: Update to match POSIX.
POSIX removed ESRCH years ago.
In resolving http://austingroupbugs.net/view.php?id=1214 it was made
clear that callers can't rely on using signal 0 to test for the
continued existence of a thread. Update the man page to make it clearer
that this doesn't generally work (even if it sometimes seems to).
See also the long explanation of why this is the case (and how to fix
your code) here:
https://android.googlesource.com/platform/bionic/+/master/docs/status.md#invalid-handling-targetsdkversion-o
---
man3/pthread_kill.3 | 25 +++++++++----------------
1 file changed, 9 insertions(+), 16 deletions(-)
diff --git a/man3/pthread_kill.3 b/man3/pthread_kill.3
index e70e2669e..fb27afd24 100644
--- a/man3/pthread_kill.3
+++ b/man3/pthread_kill.3
@@ -56,10 +56,6 @@ to
a thread in the same process as the caller.
The signal is asynchronously directed to
.IR thread .
-.PP
-If
-.I sig
-is 0, then no signal is sent, but error checking is still performed.
.SH RETURN VALUE
On success,
.BR pthread_kill ()
@@ -93,26 +89,23 @@ this action will affect the whole process.
.PP
The glibc implementation of
.BR pthread_kill ()
-gives an error
-.RB ( EINVAL )
+gives the error
+.B EINVAL
on attempts to send either of the real-time signals
used internally by the NPTL threading implementation.
See
.BR nptl (7)
for details.
.PP
-POSIX.1-2008 recommends that if an implementation detects the use
-of a thread ID after the end of its lifetime,
+The glibc implementation of
.BR pthread_kill ()
-should return the error
-.BR ESRCH .
-The glibc implementation returns this error in the cases where
-an invalid thread ID can be detected.
-But note also that POSIX says that an attempt to use a thread ID whose
-lifetime has ended produces undefined behavior,
-and an attempt to use an invalid thread ID in a call to
+tries to give the error
+.B ESRCH
+on attempts to use an invalid thread ID, but this isn't always possible.
+An attempt to use an invalid thread ID in a call to
.BR pthread_kill ()
-can, for example, cause a segmentation fault.
+can, for example, cause a segmentation fault. Android is stricter, and will
+always abort when a pthread function is given an invalid thread ID.
.SH SEE ALSO
.BR kill (2),
.BR sigaction (2),
--
2.24.0.rc1.363.gb1bccd3e3d-goog
next reply other threads:[~2019-11-12 20:36 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-12 20:36 enh [this message]
2019-11-12 21:38 ` [PATCH] pthread_kill.3: Update to match POSIX Florian Weimer
2019-11-12 21:40 ` enh
2019-11-12 21:52 ` Florian Weimer
2019-11-12 22:06 ` enh
2019-11-12 22:11 ` Florian Weimer
2019-11-12 22:22 ` enh
2019-11-12 22:28 ` Florian Weimer
2019-11-13 5:27 ` enh
2019-11-13 5:51 ` Florian Weimer
2019-11-13 5:59 ` enh
2019-11-13 6:10 ` Florian Weimer
2021-11-09 23:00 ` enh
2021-11-10 7:14 ` Florian Weimer
2021-11-12 0:01 ` enh
2021-11-12 13:02 ` Florian Weimer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAJgzZoojiRmTV_5sAXhqQciAKsQ_d+znT1OnxT0Rpa_-N_G5-Q@mail.gmail.com \
--to=enh@google.com \
--cc=linux-man@vger.kernel.org \
--cc=mtk.manpages@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).