summaryrefslogtreecommitdiff
path: root/src/kernel/proc.h
diff options
context:
space:
mode:
authordzwdz2023-01-19 23:27:12 +0100
committerdzwdz2023-01-19 23:27:12 +0100
commitda546a0822b1995efe1832c9cc57aab62ccdcf65 (patch)
tree9b558144391653d810a6a3f98cdb20623d8d0815 /src/kernel/proc.h
parent1e261597a5c5f9803a65a5b13dd71d33d501f010 (diff)
kernel: delay freeing reaped processes, slightly more strict states
Diffstat (limited to 'src/kernel/proc.h')
-rw-r--r--src/kernel/proc.h14
1 files changed, 11 insertions, 3 deletions
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. */