1 #include <unistd.h>
2 #include "pthread_impl.h"
3 #include "lock.h"
4 #ifndef __LITEOS__
5 #include "param_check.h"
6 #endif
7
pthread_kill(pthread_t t,int sig)8 int pthread_kill(pthread_t t, int sig)
9 {
10 int r;
11 sigset_t set;
12 #ifndef __LITEOS__
13 PARAM_CHECK(t);
14 #endif
15 /* Block not just app signals, but internal ones too, since
16 * pthread_kill is used to implement pthread_cancel, which
17 * must be async-cancel-safe. */
18 __block_all_sigs(&set);
19 LOCK(t->killlock);
20 #ifndef __LITEOS__
21 r = t->tid ? -__syscall(__NR_tgkill, getpid(), t->tid, sig)
22 : (sig+0U >= _NSIG ? EINVAL : 0);
23 #else
24 r = t->tid ? -__syscall(SYS_tkill, t->tid, sig)
25 : (sig+0U >= _NSIG ? EINVAL : 0);
26 #endif
27 UNLOCK(t->killlock);
28 __restore_sigs(&set);
29 return r;
30 }
31