X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Fsignal%2Fraise.c;h=c0814fad0ddfc886c00925aa81e0a7e9ec2a2098;hb=330fd96213da324f9164081df9a5226790d7c4ec;hp=f437d23f2b4d2a311efb0d96b3ada00373a8a780;hpb=370f78f2c80c64b7b0780a01e672494a26b5678e;p=musl diff --git a/src/signal/raise.c b/src/signal/raise.c index f437d23f..c0814fad 100644 --- a/src/signal/raise.c +++ b/src/signal/raise.c @@ -1,18 +1,17 @@ #include #include +#include #include "syscall.h" +#include "pthread_impl.h" int raise(int sig) { int pid, tid, ret; - /* Getting the pid/tid pair is not atomic, and could give wrong - * result if a fork occurs in a signal handler between the two - * syscalls. Use the tgkill syscall's ESRCH semantics to detect - * this condition and retry. */ - do { - tid = syscall0(__NR_gettid); - pid = syscall0(__NR_getpid); - ret = syscall3(__NR_tgkill, pid, tid, sig); - } while (ret<0 && errno == ESRCH); + sigset_t set; + __syscall(SYS_rt_sigprocmask, SIG_BLOCK, SIGALL_SET, &set, __SYSCALL_SSLEN); + tid = syscall(SYS_gettid); + pid = syscall(SYS_getpid); + ret = syscall(SYS_tgkill, pid, tid, sig); + __syscall(SYS_rt_sigprocmask, SIG_SETMASK, &set, 0, __SYSCALL_SSLEN); return ret; }