From c102c4b726d109f8d191b1b9b1f4a4fc575921c1 Mon Sep 17 00:00:00 2001 From: jewelcodes Date: Wed, 20 Nov 2024 13:19:29 -0500 Subject: [PATCH] ipc: refined signal handler structures --- src/include/kernel/signal.h | 2 +- src/ipc/signal.c | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/include/kernel/signal.h b/src/include/kernel/signal.h index a6e9156..44a39a6 100644 --- a/src/include/kernel/signal.h +++ b/src/include/kernel/signal.h @@ -88,7 +88,7 @@ struct sigaction { union { void (*sa_handler)(int); void (*sa_sigaction)(int, siginfo_t *, void *); - } handler; + }; sigset_t sa_mask; int sa_flags; diff --git a/src/ipc/signal.c b/src/ipc/signal.c index 81a57d6..41fe19e 100644 --- a/src/ipc/signal.c +++ b/src/ipc/signal.c @@ -88,11 +88,11 @@ int sigismember(sigset_t *set, int signum) { */ void *signalDefaults() { - uintptr_t *ptr = malloc((MAX_SIGNAL+1) * sizeof(uintptr_t)); + struct sigaction *ptr = malloc((MAX_SIGNAL+1) * sizeof(struct sigaction)); if(!ptr) return NULL; for(int i = 0; i < MAX_SIGNAL; i++) - ptr[i] = (uintptr_t) SIG_DFL; // default + ptr[i].sa_handler = SIG_DFL; // default return (void *) ptr; } @@ -148,10 +148,10 @@ int signalDefaultHandler(int signum) { void *signalClone(const void *h) { if(!h) return signalDefaults(); - void *new = malloc((MAX_SIGNAL+1) * sizeof(uintptr_t)); + void *new = malloc((MAX_SIGNAL+1) * sizeof(struct sigaction)); if(!new) return NULL; - return memcpy(new, h, (MAX_SIGNAL+1) * sizeof(uintptr_t)); + return memcpy(new, h, (MAX_SIGNAL+1) * sizeof(struct sigaction)); } /* kill(): sends a signal to a process or thread @@ -258,8 +258,8 @@ void signalHandle(Thread *t) { releaseLock(&t->lock); int signum = s->signum; - uintptr_t *handlers = (uintptr_t *) t->signals; - uintptr_t handler = handlers[signum]; + struct sigaction *handlers = (struct sigaction *) t->signals; + uintptr_t handler = (uintptr_t) handlers[signum].sa_handler; int def = 0; free(s);