summaryrefslogtreecommitdiff
path: root/src/kernel/proc.c
diff options
context:
space:
mode:
authordzwdz2022-05-06 14:41:58 +0200
committerdzwdz2022-05-06 14:41:58 +0200
commit8ee57c885a72854d1884a886de4db538a8468e07 (patch)
tree9c9f2eea8d7667ce7ed45dd71b6bbde40ce93f7e /src/kernel/proc.c
parent53d21d1ccb75004d0085efedd688b695707a3138 (diff)
syscalls: merge fork() and fs_fork2()
Diffstat (limited to 'src/kernel/proc.c')
-rw-r--r--src/kernel/proc.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/kernel/proc.c b/src/kernel/proc.c
index ed257fd..7ef4579 100644
--- a/src/kernel/proc.c
+++ b/src/kernel/proc.c
@@ -44,7 +44,7 @@ struct process *process_seed(struct kmain_info *info) {
struct process *process_fork(struct process *parent, int flags) {
struct process *child = kmalloc(sizeof *child);
- memcpy(child, parent, sizeof *child);
+ memcpy(child, parent, sizeof *child); // TODO manually set fields
child->pages = pagedir_copy(parent->pages);
child->sibling = parent->child;
@@ -55,9 +55,13 @@ struct process *process_fork(struct process *parent, int flags) {
parent->handled_req = NULL; // TODO control this with a flag
- if (child->controlled) {
- child->controlled->potential_handlers++;
- child->controlled->refcount++;
+ if ((flags & FORK_NEWFS) == 0) {
+ if (child->controlled) {
+ child->controlled->potential_handlers++;
+ child->controlled->refcount++;
+ }
+ } else {
+ child->controlled = NULL;
}
for (handle_t h = 0; h < HANDLE_MAX; h++) {