don't fail pthread_sigmask/sigprocmask on invalid how when set is null
[musl.git] / src / thread / pthread_sigmask.c
blobf188782a3277ed6dbcadb1cb8b8af90dc73efbdd
1 #include <signal.h>
2 #include <errno.h>
3 #include "syscall.h"
5 int pthread_sigmask(int how, const sigset_t *restrict set, sigset_t *restrict old)
7 int ret;
8 if (set && (unsigned)how - SIG_BLOCK > 2U) return EINVAL;
9 ret = -__syscall(SYS_rt_sigprocmask, how, set, old, _NSIG/8);
10 if (!ret && old) {
11 if (sizeof old->__bits[0] == 8) {
12 old->__bits[0] &= ~0x380000000ULL;
13 } else {
14 old->__bits[0] &= ~0x80000000UL;
15 old->__bits[1] &= ~0x3UL;
18 return ret;