From 4286b14839c0c4ec016d816e426660f6685ae349 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Thu, 7 May 2020 18:10:22 +0200 Subject: Fixed many bugs with wait() and fork() This also adds many race conditions which really need to be fixed.. --- src/kernel/syscall/actions/sys_exec.c | 1 + src/kernel/syscall/actions/sys_fork.c | 5 ++++- src/kernel/syscall/actions/sys_wait.c | 3 +++ 3 files changed, 8 insertions(+), 1 deletion(-) (limited to 'src/kernel/syscall/actions') diff --git a/src/kernel/syscall/actions/sys_exec.c b/src/kernel/syscall/actions/sys_exec.c index 049d085..99c6539 100644 --- a/src/kernel/syscall/actions/sys_exec.c +++ b/src/kernel/syscall/actions/sys_exec.c @@ -1,5 +1,6 @@ #include #include +#include u32 sys_exec(char *path) { diff --git a/src/kernel/syscall/actions/sys_fork.c b/src/kernel/syscall/actions/sys_fork.c index f0a5711..084659e 100644 --- a/src/kernel/syscall/actions/sys_fork.c +++ b/src/kernel/syscall/actions/sys_fork.c @@ -4,16 +4,19 @@ #include #include #include +#include u32 sys_fork(struct regs *r) { + cli(); struct page_directory *dir = paging_copy_user_directory(current_proc->cr3); struct process *proc = process_make_new(); proc->cr3 = dir; memcpy(&proc->registers, r, sizeof(struct regs)); proc->registers.eax = proc->pid; - proc->pid = current_proc->pid; + proc->pid = current_proc->pid + 1; + sti(); process_spawn(proc); return 0; diff --git a/src/kernel/syscall/actions/sys_wait.c b/src/kernel/syscall/actions/sys_wait.c index 7cea24f..6015b8b 100644 --- a/src/kernel/syscall/actions/sys_wait.c +++ b/src/kernel/syscall/actions/sys_wait.c @@ -1,7 +1,10 @@ +#include #include +#include u32 sys_wait(u32 pid, u32 *status, u32 options) { + sti(); u32 ret; if (pid < 0) { // Wait for any process in gid to die -- cgit v1.2.3