aboutsummaryrefslogtreecommitdiff
path: root/src/kernel/syscall/actions/sys_fork.c
blob: f0a5711d89fa68c6201ce9447608076d910af242 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <stdint.h>
#include <interrupts/interrupts.h>
#include <memory/paging.h>
#include <tasks/process.h>
#include <lib/lib.h>
#include <system.h>

u32 sys_fork(struct regs *r)
{
	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;

	process_spawn(proc);

	return 0;
}