1 /* Send a signal to a specific pthread. Stub version.
2 Copyright (C) 2014-2021 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
21 #include <shlib-compat.h>
24 __pthread_kill_internal (pthread_t threadid
, int signo
)
27 struct pthread
*pd
= (struct pthread
*) threadid
;
29 if (pd
== THREAD_SELF
)
30 /* It is a special case to handle raise() implementation after a vfork
31 call (which does not update the PD tid field). */
32 tid
= INLINE_SYSCALL_CALL (gettid
);
34 /* Force load of pd->tid into local variable or register. Otherwise
35 if a thread exits between ESRCH test and tgkill, we might return
36 EINVAL, because pd->tid would be cleared by the kernel. */
37 tid
= atomic_forced_read (pd
->tid
);
40 if (__glibc_likely (tid
> 0))
42 pid_t pid
= __getpid ();
44 val
= INTERNAL_SYSCALL_CALL (tgkill
, pid
, tid
, signo
);
45 val
= (INTERNAL_SYSCALL_ERROR_P (val
)
46 ? INTERNAL_SYSCALL_ERRNO (val
) : 0);
55 __pthread_kill (pthread_t threadid
, int signo
)
57 /* Disallow sending the signal we use for cancellation, timers,
58 for the setxid implementation. */
59 if (__is_internal_signal (signo
))
62 return __pthread_kill_internal (threadid
, signo
);
64 /* Some architectures (for instance arm) might pull raise through libgcc, so
65 avoid the symbol version if it ends up being used on ld.so. */
67 libc_hidden_def (__pthread_kill
)
68 versioned_symbol (libc
, __pthread_kill
, pthread_kill
, GLIBC_2_34
);
70 # if OTHER_SHLIB_COMPAT (libpthread, GLIBC_2_0, GLIBC_2_34)
71 compat_symbol (libc
, __pthread_kill
, pthread_kill
, GLIBC_2_0
);