From da546a0822b1995efe1832c9cc57aab62ccdcf65 Mon Sep 17 00:00:00 2001 From: dzwdz Date: Thu, 19 Jan 2023 23:27:12 +0100 Subject: kernel: delay freeing reaped processes, slightly more strict states --- src/kernel/proc.h | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src/kernel/proc.h') diff --git a/src/kernel/proc.h b/src/kernel/proc.h index c51151b..b95e901 100644 --- a/src/kernel/proc.h +++ b/src/kernel/proc.h @@ -12,6 +12,10 @@ enum process_state { PS_DYING, /* during process_kill - mostly treated as alive */ PS_TOREAP, /* return message not collected */ PS_TOMBSTONE, /* fully dead, supports alive children */ + /* not in the process tree, waits for free. + * *sibling holds a linked list of all the FORGOTTEN processes */ + PS_FORGOTTEN, + PS_FREED, /* only meant to detect double frees */ PS_WAITS4CHILDDEATH, PS_WAITS4FS, @@ -22,7 +26,12 @@ enum process_state { PS_LAST, }; -#define proc_alive(p) (p && p->state != PS_TOREAP && p->state != PS_TOMBSTONE) +#define proc_alive(p) (p \ + && p->state != PS_TOREAP \ + && p->state != PS_TOMBSTONE \ + && p->state != PS_FORGOTTEN \ + && p->state != PS_FREED \ + ) struct process { struct pagedir *pages; @@ -88,8 +97,7 @@ struct process *process_fork(struct process *parent, int flags); void process_kill(struct process *proc, int ret); /** Kills all descendants. */ void process_filicide(struct process *proc, int ret); -/** Tries to reap a dead process / free a tombstone. - * Can also free all dead parents of *dead. Be careful. */ +/** Tries to reap a dead process / free a tombstone. */ void process_tryreap(struct process *dead); /** Switches execution to any running process. */ -- cgit v1.2.3