Patch by Vasilis Kaoutsis: Check for a valid signal number before

doing something. If the signal is not valid, set errno and return -1.
Mini style changes by myself.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22728 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold 2007-10-25 22:01:16 +00:00
parent 2bbf13b7a5
commit 77c02b906b

View File

@ -7,8 +7,8 @@
*/
#include <errno.h>
#include <signal.h>
#include <syscalls.h>
@ -31,7 +31,14 @@ sigfillset(sigset_t *set)
int
sigismember(const sigset_t *set, int sig)
{
sigset_t mask = (((sigset_t) 1) << (( sig ) - 1)) ;
sigset_t mask;
if (sig <= 0 || sig >= NSIG) {
errno = EINVAL;
return -1;
}
mask = (((sigset_t)1) << (sig - 1)) ;
return (*set & mask) ? 1 : 0 ;
}
@ -39,7 +46,14 @@ sigismember(const sigset_t *set, int sig)
int
sigaddset(sigset_t *set, int sig)
{
sigset_t mask = (((sigset_t) 1) << (( sig ) - 1)) ;
sigset_t mask;
if (sig <= 0 || sig >= NSIG) {
errno = EINVAL;
return -1;
}
mask = (((sigset_t)1) << (sig - 1)) ;
*set |= mask;
return 0;
}
@ -48,8 +62,14 @@ sigaddset(sigset_t *set, int sig)
int
sigdelset(sigset_t *set, int sig)
{
sigset_t mask = (((sigset_t) 1) << (( sig ) - 1)) ;
sigset_t mask;
if (sig <= 0 || sig >= NSIG) {
errno = EINVAL;
return -1;
}
mask = (((sigset_t)1) << (sig - 1)) ;
*set &= ~mask;
return 0;
}