mirror of git://git.musl-libc.org/musl
fix error handling for pthread_sigmask
it must return errno, not -1, and should reject invalud values for how.
This commit is contained in:
parent
3f5420bcda
commit
500c969f05
|
@ -1,4 +1,5 @@
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
#include <errno.h>
|
||||||
#include "syscall.h"
|
#include "syscall.h"
|
||||||
#include "libc.h"
|
#include "libc.h"
|
||||||
#include "pthread_impl.h"
|
#include "pthread_impl.h"
|
||||||
|
@ -11,6 +12,10 @@ int __libc_sigprocmask(int how, const sigset_t *set, sigset_t *old)
|
||||||
int __sigprocmask(int how, const sigset_t *set, sigset_t *old)
|
int __sigprocmask(int how, const sigset_t *set, sigset_t *old)
|
||||||
{
|
{
|
||||||
sigset_t tmp;
|
sigset_t tmp;
|
||||||
|
if (how > 2U) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
/* Disallow blocking thread control signals */
|
/* Disallow blocking thread control signals */
|
||||||
if (set && how != SIG_UNBLOCK) {
|
if (set && how != SIG_UNBLOCK) {
|
||||||
tmp = *set;
|
tmp = *set;
|
||||||
|
@ -22,4 +27,3 @@ int __sigprocmask(int how, const sigset_t *set, sigset_t *old)
|
||||||
}
|
}
|
||||||
|
|
||||||
weak_alias(__sigprocmask, sigprocmask);
|
weak_alias(__sigprocmask, sigprocmask);
|
||||||
weak_alias(__sigprocmask, pthread_sigmask);
|
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
#include <signal.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <pthread.h>
|
||||||
|
|
||||||
|
int pthread_sigmask(int how, const sigset_t *set, sigset_t *old)
|
||||||
|
{
|
||||||
|
int ret = sigprocmask(how, set, old);
|
||||||
|
if (ret) return errno;
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in New Issue