From 896a0a04f94821a6ad6f0e8a3ad34b9d3408e214 Mon Sep 17 00:00:00 2001 From: 0x35c <> Date: Sun, 30 Nov 2025 14:24:33 +0100 Subject: [PATCH] fix: set content to the new thread_list node fix: copy child to the current_pcb --- src/multitasking/fork.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/multitasking/fork.c b/src/multitasking/fork.c index 1e3cd51..f34efe9 100644 --- a/src/multitasking/fork.c +++ b/src/multitasking/fork.c @@ -61,8 +61,8 @@ static int deep_copy(struct pcb *new_pcb) return -1; } PD[i + USER_PT_END / 2] = (uint32_t)new_pt | INIT_FLAGS; - if (!copy_pt(PTE2VA(1023, i), PTE2VA(1023, i + USER_PT_END / 2), - i)) { + if (copy_pt(PTE2VA(1023, i), PTE2VA(1023, i + USER_PT_END / 2), + i) < 0) { free_pts(); return -1; } @@ -83,7 +83,7 @@ pid_t fork(void) return -1; } new_pcb->daddy = current_pcb; - lst_add_back(&new_pcb->children, new_node); + lst_add_back(¤t_pcb->children, new_node); if (deep_copy(new_pcb) < 0) goto error; @@ -105,6 +105,7 @@ pid_t fork(void) memcpy(new_content, it->content, sizeof(struct tcb)); new_content->process = new_pcb; e->next = NULL; + e->content = new_content; prev = e; }