1 /* Copyright (C) 2009-2018 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Ulrich Drepper <drepper@redhat.com>, 2009.
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 <http://www.gnu.org/licenses/>. */
29 pthread_sigqueue (pthread_t threadid
, int signo
, const union sigval value
)
31 #ifdef __NR_rt_tgsigqueueinfo
32 struct pthread
*pd
= (struct pthread
*) threadid
;
34 /* Make sure the descriptor is valid. */
35 if (DEBUGGING_P
&& INVALID_TD_P (pd
))
36 /* Not a valid thread handle. */
39 /* Force load of pd->tid into local variable or register. Otherwise
40 if a thread exits between ESRCH test and tgkill, we might return
41 EINVAL, because pd->tid would be cleared by the kernel. */
42 pid_t tid
= atomic_forced_read (pd
->tid
);
43 if (__glibc_unlikely (tid
<= 0))
44 /* Not a valid thread handle. */
47 /* Disallow sending the signal we use for cancellation, timers,
48 for the setxid implementation. */
49 if (signo
== SIGCANCEL
|| signo
== SIGTIMER
|| signo
== SIGSETXID
)
52 pid_t pid
= getpid ();
54 /* Set up the siginfo_t structure. */
56 memset (&info
, '\0', sizeof (siginfo_t
));
57 info
.si_signo
= signo
;
58 info
.si_code
= SI_QUEUE
;
60 info
.si_uid
= getuid ();
61 info
.si_value
= value
;
63 /* We have a special syscall to do the work. */
64 INTERNAL_SYSCALL_DECL (err
);
66 int val
= INTERNAL_SYSCALL_CALL (rt_tgsigqueueinfo
, err
, pid
, tid
, signo
,
68 return (INTERNAL_SYSCALL_ERROR_P (val
, err
)
69 ? INTERNAL_SYSCALL_ERRNO (val
, err
) : 0);