eliminate use of cached pid from thread structure
[oweals/musl.git] / src / thread / pthread_kill.c
index 9d85fa5b497fb06afcabf9d1258cc8e446b3dabd..acdb1ea6173c27284ed946a63831855908f28f19 100644 (file)
@@ -1,7 +1,10 @@
-#define SYSCALL_RETURN_ERRNO
 #include "pthread_impl.h"
 
 int pthread_kill(pthread_t t, int sig)
 {
-       return syscall3(__NR_tgkill, t->pid, t->tid, sig);
+       int r;
+       __lock(t->killlock);
+       r = t->dead ? ESRCH : -__syscall(SYS_tkill, t->tid, sig);
+       __unlock(t->killlock);
+       return r;
 }