fix: fork: set child espat the right postion

This commit is contained in:
Starnakin 2025-01-29 12:41:57 +01:00
parent 1ca8c68cf5
commit 69686a2c91

View File

@ -1,6 +1,7 @@
#include "interrupts.h"
#include "string.h"
#include "task.h"
#include "types.h"
u16 fork(void)
{
@ -11,6 +12,9 @@ u16 fork(void)
child->daddy = current_task;
current_task->child = child;
memcpy(child->esp0, current_task->esp0, STACK_SIZE);
u32 *daddy_esp = 0;
asm("movl %%esp, %0" : "=m"(daddy_esp));
child->esp = child->esp0 + (daddy_esp - current_task->esp0);
toris();
return current_task == child ? 0 : child->uid;
}