[all-commits] [llvm/llvm-project] 340785: [libc] Implement pthread_kill (#222625)

Pavel Labath via All-commits all-commits at lists.llvm.org
Fri Sep 11 03:23:44 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 3407850c31e556ffb52d22b09c9405ad67a59f64
      https://github.com/llvm/llvm-project/commit/3407850c31e556ffb52d22b09c9405ad67a59f64
  Author: Pavel Labath <pavel at labath.sk>
  Date:   2026-09-11 (Fri, 11 Sep 2026)

  Changed paths:
    M libc/config/linux/aarch64/entrypoints.txt
    M libc/config/linux/riscv/entrypoints.txt
    M libc/config/linux/x86_64/entrypoints.txt
    M libc/include/CMakeLists.txt
    M libc/include/signal.yaml
    M libc/src/__support/OSUtil/linux/syscall_wrappers/CMakeLists.txt
    M libc/src/__support/OSUtil/linux/syscall_wrappers/raise.h
    A libc/src/__support/OSUtil/linux/syscall_wrappers/tgkill.h
    M libc/src/__support/threads/linux/CMakeLists.txt
    M libc/src/__support/threads/linux/thread.cpp
    M libc/src/__support/threads/thread.h
    M libc/src/signal/CMakeLists.txt
    M libc/src/signal/linux/CMakeLists.txt
    A libc/src/signal/linux/pthread_kill.cpp
    A libc/src/signal/pthread_kill.h
    M libc/test/integration/src/pthread/CMakeLists.txt
    A libc/test/integration/src/pthread/pthread_kill_test.cpp
    M utils/bazel/llvm-project-overlay/libc/BUILD.bazel

  Log Message:
  -----------
  [libc] Implement pthread_kill (#222625)

The implementation delegates to Thread::kill, which uses tgkill to
target the thread ID.

The main complication is handling zombie threads. POSIX.1-2024 requires
that pthread_kill on a terminated (zombie) thread does not return ESRCH
because the pthread_t handle is still valid. The Linux kernel reaps
threads immediately on exit, so calling tgkill on an exited thread would
return ESRCH (or worse, target a recycled TID). To handle this:
- we check the thread's detach_state first. If it's already EXITING, we
simply return success without calling tgkill (a zombie thread cannot
handle signals anyway).
- if the thread exits concurrently and tgkill returns -ESRCH, we assume
it transitioned to a zombie and treat it as success.

I've also added a tgkill syscall wrapper and replaced one raw usage of
SYS_tgkill.

I've added an integration test covering signal delivery to self and
other threads, signal 0 checks, invalid signals, zombie threads, and
signal mask interactions.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list