X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Fthread%2Fpthread_kill.c;h=79ddb20978f7513f35789209d3d4b3be13df1a46;hb=c5f4b2dfea320356f69445dc1adf8f73596a3c36;hp=acdb1ea6173c27284ed946a63831855908f28f19;hpb=83dc6eb087633abcf5608ad651d3b525ca2ec35e;p=musl diff --git a/src/thread/pthread_kill.c b/src/thread/pthread_kill.c index acdb1ea6..79ddb209 100644 --- a/src/thread/pthread_kill.c +++ b/src/thread/pthread_kill.c @@ -1,10 +1,18 @@ #include "pthread_impl.h" +#include "lock.h" int pthread_kill(pthread_t t, int sig) { int r; - __lock(t->killlock); - r = t->dead ? ESRCH : -__syscall(SYS_tkill, t->tid, sig); - __unlock(t->killlock); + sigset_t set; + /* Block not just app signals, but internal ones too, since + * pthread_kill is used to implement pthread_cancel, which + * must be async-cancel-safe. */ + __block_all_sigs(&set); + LOCK(t->killlock); + r = t->tid ? -__syscall(SYS_tkill, t->tid, sig) + : (sig+0U >= _NSIG ? EINVAL : 0); + UNLOCK(t->killlock); + __restore_sigs(&set); return r; }