X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;ds=sidebyside;f=src%2Fthread%2Fpthread_kill.c;h=79ddb20978f7513f35789209d3d4b3be13df1a46;hb=760f5d7efed4d4761875334f8c4e6398be308cc9;hp=15f70fb97a18b1b7ca4334e44425a7f943cee0f6;hpb=c89f130f39b413d1fb1733166ca63d694685c529;p=musl diff --git a/src/thread/pthread_kill.c b/src/thread/pthread_kill.c index 15f70fb9..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_tgkill, t->pid, 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; }