1 /* Copyright (C) 2009-2024 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <https://www.gnu.org/licenses/>. */
25 #include <shlib-compat.h>
28 __pthread_sigqueue (pthread_t threadid
, int signo
, const union sigval value
)
30 #ifdef __NR_rt_tgsigqueueinfo
31 struct pthread
*pd
= (struct pthread
*) threadid
;
33 /* Force load of pd->tid into local variable or register. Otherwise
34 if a thread exits between ESRCH test and tgkill, we might return
35 EINVAL, because pd->tid would be cleared by the kernel. */
36 pid_t tid
= atomic_forced_read (pd
->tid
);
37 if (__glibc_unlikely (tid
<= 0))
38 /* Not a valid thread handle. */
41 /* Disallow sending the signal we use for cancellation, timers,
42 for the setxid implementation. */
43 if (signo
== SIGCANCEL
|| signo
== SIGTIMER
|| signo
== SIGSETXID
)
46 pid_t pid
= getpid ();
48 /* Set up the siginfo_t structure. */
50 memset (&info
, '\0', sizeof (siginfo_t
));
51 info
.si_signo
= signo
;
52 info
.si_code
= SI_QUEUE
;
54 info
.si_uid
= __getuid ();
55 info
.si_value
= value
;
57 /* We have a special syscall to do the work. */
58 int val
= INTERNAL_SYSCALL_CALL (rt_tgsigqueueinfo
, pid
, tid
, signo
,
60 return (INTERNAL_SYSCALL_ERROR_P (val
)
61 ? INTERNAL_SYSCALL_ERRNO (val
) : 0);
66 versioned_symbol (libc
, __pthread_sigqueue
, pthread_sigqueue
, GLIBC_2_34
);
68 #if OTHER_SHLIB_COMPAT (libpthread, GLIBC_2_11, GLIBC_2_34)
69 compat_symbol (libpthread
, __pthread_sigqueue
, pthread_sigqueue
, GLIBC_2_11
);