Skip to content

Commit

Permalink
ipc: signal numbering fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jewelcodes committed Nov 20, 2024
1 parent c102c4b commit d9b90f0
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/ipc/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ int sigfillset(sigset_t *set) {
*/

int sigaddset(sigset_t *set, int signum) {
if(signum < 0 || signum > MAX_SIGNAL)
if(signum <= 0 || signum > MAX_SIGNAL)
return -EINVAL;

*set |= (1 << signum);
Expand All @@ -61,7 +61,7 @@ int sigaddset(sigset_t *set, int signum) {
*/

int sigdelset(sigset_t *set, int signum) {
if(signum < 0 || signum > MAX_SIGNAL)
if(signum <= 0 || signum > MAX_SIGNAL)
return -EINVAL;

*set &= ~(1 << signum);
Expand All @@ -75,7 +75,7 @@ int sigdelset(sigset_t *set, int signum) {
*/

int sigismember(sigset_t *set, int signum) {
if(signum < 0 || signum > MAX_SIGNAL)
if(signum <= 0 || signum > MAX_SIGNAL)
return -EINVAL;

if(*set & (1 << signum)) return 1;
Expand Down Expand Up @@ -257,7 +257,7 @@ void signalHandle(Thread *t) {

releaseLock(&t->lock);

int signum = s->signum;
int signum = s->signum - 1; // change to zero-based
struct sigaction *handlers = (struct sigaction *) t->signals;
uintptr_t handler = (uintptr_t) handlers[signum].sa_handler;
int def = 0;
Expand All @@ -269,7 +269,7 @@ void signalHandle(Thread *t) {
case (uintptr_t) SIG_HOLD:
return;
case (uintptr_t) SIG_DFL:
def = signalDefaultHandler(signum);
def = signalDefaultHandler(signum + 1);
break;
}

Expand Down

0 comments on commit d9b90f0

Please sign in to comment.