Skip to content

Commit

Permalink
sched: allocate memory for signal context in fork()
Browse files Browse the repository at this point in the history
  • Loading branch information
jewelcodes committed Nov 26, 2024
1 parent 2fdd8d7 commit 8adc92f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/sched/fork.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,15 @@ pid_t fork(Thread *t) {
p->threads[0]->pid = pid;
p->threads[0]->tid = pid;
p->threads[0]->context = calloc(1, PLATFORM_CONTEXT_SIZE);
p->threads[0]->signalContext = calloc(1, PLATFORM_CONTEXT_SIZE);
p->threads[0]->highest = t->highest;
p->threads[0]->pages = t->pages;

// NOTE: fork() only clones one thread, which is why we're not cloning the
// entire process memory, but just the calling thread
p->pages = t->pages;

if(!p->threads[0]->context) {
if(!p->threads[0]->context || !p->threads[0]->signalContext) {
free(p->threads[0]);
free(p->threads);
free(p);
Expand Down

0 comments on commit 8adc92f

Please sign in to comment.