syscall overhaul part two - unify public and internal syscall interface
[musl] / src / signal / sigprocmask.c
index db27f12..96d0847 100644 (file)
@@ -1,4 +1,5 @@
 #include <signal.h>
+#include <errno.h>
 #include "syscall.h"
 #include "libc.h"
 #include "pthread_impl.h"
@@ -11,8 +12,12 @@ int __libc_sigprocmask(int how, const sigset_t *set, sigset_t *old)
 int __sigprocmask(int how, const sigset_t *set, sigset_t *old)
 {
        sigset_t tmp;
+       if (how > 2U) {
+               errno = EINVAL;
+               return -1;
+       }
        /* Disallow blocking thread control signals */
-       if (how != SIG_UNBLOCK) {
+       if (set && how != SIG_UNBLOCK) {
                tmp = *set;
                set = &tmp;
                sigdelset(&tmp, SIGCANCEL);
@@ -22,4 +27,3 @@ int __sigprocmask(int how, const sigset_t *set, sigset_t *old)
 }
 
 weak_alias(__sigprocmask, sigprocmask);
-weak_alias(__sigprocmask, pthread_sigmask);