From 530d2292182ae4e35e4a13929831a6803f517128 Mon Sep 17 00:00:00 2001 From: dzwdz Date: Fri, 6 May 2022 13:33:37 +0200 Subject: kernel/proc: simplify `process_free()` --- src/kernel/proc.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'src/kernel/proc.c') diff --git a/src/kernel/proc.c b/src/kernel/proc.c index 2a35acc..54efe85 100644 --- a/src/kernel/proc.c +++ b/src/kernel/proc.c @@ -94,18 +94,8 @@ void process_free(struct process *p) { assert(p->state == PS_DEAD); assert(!p->child); - // also could be done on kill - vfs_mount_remref(p->mount); - p->mount = NULL; - - if (p->controlled) { - vfs_backend_refdown(p->controlled); - p->controlled = NULL; - } - if (!p->parent) return; process_forget(p); - pagedir_free(p->pages); // TODO could be done on kill kfree(p); } @@ -244,9 +234,15 @@ void process_kill(struct process *p, int ret) { for (handle_t h = 0; h < HANDLE_MAX; h++) handle_close(p->handles[h]); + vfs_mount_remref(p->mount); + p->mount = NULL; + process_transition(p, PS_DEAD); p->death_msg = ret; + if (p->parent) + pagedir_free(p->pages); // TODO put init's pages in the allocator + // TODO VULN unbounded recursion struct process *c2; for (struct process *c = p->child; c; c = c2) { -- cgit v1.2.3