global cleanup to use the new syscall interface
[musl] / src / signal / raise.c
index f437d23..9948f41 100644 (file)
@@ -2,17 +2,17 @@
 #include <errno.h>
 #include "syscall.h"
 
+int __sigprocmask(int, const sigset_t *, sigset_t *);
+
 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;
+       sigfillset(&set);
+       __sigprocmask(SIG_BLOCK, &set, &set);
+       tid = syscall(SYS_gettid);
+       pid = syscall(SYS_getpid);
+       ret = syscall(SYS_tgkill, pid, tid, sig);
+       __sigprocmask(SIG_SETMASK, &set, 0);
        return ret;
 }