nptl: Implement raise in terms of pthread_kill

System Internals / glibc - Adhemerval Zanella [linaro.org] - 9 June 2021 18:16 UTC

Now that pthread_kill is provided by libc.so it is possible to implement the generic POSIX implementation as 'pthread_kill(pthread_self(), sig)'.

For Linux implementation, pthread_kill read the targeting TID from the TCB. For raise, this it not possible because it would make raise fail when issue after vfork (where creates the resulting process has a different TID from the parent, but its TCB is not updated as for pthread_create). To make raise use pthread_kill, it is make usable from vfork by getting the target thread id through gettid syscall.

Checked on x86_64-linux-gnu and aarch64-linux-gnu.

f779b1efb3 nptl: Implement raise in terms of pthread_kill
include/pthread.h | 5 ++++
nptl/Makefile | 1 +
nptl/pthreadP.h | 4 +++-
nptl/pthread_kill.c | 42 ++++++++++++++++++++++-----------
nptl/pthread_self.c | 4 +++-
sysdeps/htl/pthreadP.h | 2 --
sysdeps/posix/raise.c | 11 +++++++--
sysdeps/unix/sysv/linux/raise.c | 52 -----------------------------------------
8 files changed, 50 insertions(+), 71 deletions(-)

Upstream: sourceware.org


  • Share