diff options
author | dzwdz | 2022-04-28 19:59:37 +0200 |
---|---|---|
committer | dzwdz | 2022-04-28 19:59:37 +0200 |
commit | cad354b671cc7fa783a3fd0631a0f85c40b69a0c (patch) | |
tree | 825119fd36007c097d336d145185678bf47132c3 /src/kernel/proc.c | |
parent | 7c96f9c03502e0c60f23f4c550d12a629f3b3daf (diff) |
kernel/proc: automatically free processes given the chance
Diffstat (limited to 'src/kernel/proc.c')
-rw-r--r-- | src/kernel/proc.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/kernel/proc.c b/src/kernel/proc.c index f17b94c..57b9669 100644 --- a/src/kernel/proc.c +++ b/src/kernel/proc.c @@ -86,7 +86,6 @@ void process_forget(struct process *p) { } void process_free(struct process *p) { - // TODO only attempt to free, return a bool bool valid = false; if (p->state == PS_DEADER) valid = true; if (p->state == PS_DEAD && (!p->parent @@ -121,7 +120,7 @@ static _Noreturn void process_idle(void) { if (len == 0) shutdown(); - if (process_first->state == PS_DEAD) { + if (process_first->state == PS_DEAD || process_first->state == PS_DEADER) { /* special case: if the system is about to shut off, stop waiting for IRQs * usually this would be an issue because it would let processes know if * they're using the kernel handler, but the system is shutting off anyways, @@ -305,6 +304,10 @@ int process_try2collect(struct process *dead) { assert(dead->state == PS_DEAD); + if (!parent) { + process_transition(dead, PS_DEADER); + return -1; + } switch (parent->state) { case PS_WAITS4CHILDDEATH: ret = dead->death_msg; @@ -316,6 +319,7 @@ int process_try2collect(struct process *dead) { case PS_DEAD: case PS_DEADER: + case PS_DUMMY: process_transition(dead, PS_DEADER); return -1; |