Skip to content

Commit

Permalink
ipc: signal default handler setup
Browse files Browse the repository at this point in the history
  • Loading branch information
jewelcodes committed Nov 5, 2024
1 parent df0c52e commit 24ec52d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/include/kernel/signal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 *);
15 changes: 15 additions & 0 deletions src/ipc/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

#include <errno.h>
#include <stdlib.h>
#include <kernel/signal.h>
#include <kernel/sched.h>

Expand Down Expand Up @@ -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;
}

0 comments on commit 24ec52d

Please sign in to comment.