From 24ec52d921c8f7d4e898264335ef8c7797d2d961 Mon Sep 17 00:00:00 2001 From: jewelcodes Date: Tue, 5 Nov 2024 13:49:14 -0500 Subject: [PATCH] ipc: signal default handler setup --- src/include/kernel/signal.h | 2 ++ src/ipc/signal.c | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/include/kernel/signal.h b/src/include/kernel/signal.h index 5fe7586..b32c138 100644 --- a/src/include/kernel/signal.h +++ b/src/include/kernel/signal.h @@ -76,5 +76,7 @@ int sigaddset(sigset_t *, int); int sigdelset(sigset_t *, int); int sigismember(sigset_t *, int); +void *signalDefaults(); + int kill(Thread *, pid_t, int); int sigaction(Thread *, int, const struct sigaction *, struct sigaction *); diff --git a/src/ipc/signal.c b/src/ipc/signal.c index 1e735b7..b158359 100644 --- a/src/ipc/signal.c +++ b/src/ipc/signal.c @@ -6,6 +6,7 @@ */ #include +#include #include #include @@ -77,3 +78,17 @@ int sigismember(sigset_t *set, int signum) { else return 0; } +/* signalDefaults(): sets up the default signal handlers for a thread + * params: none + * returns: pointer to the signal handler array, NULL on fail + */ + +void *signalDefaults() { + uintptr_t *ptr = calloc(MAX_SIGNAL+1, sizeof(uintptr_t)); + if(!ptr) return NULL; + + for(int i = 0; i < MAX_SIGNAL; i++) + *ptr = (uintptr_t) SIG_DFL; // default + + return (void *) ptr; +}