summaryrefslogtreecommitdiff
path: root/src/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'src/kernel')
-rw-r--r--src/kernel/main.c5
-rw-r--r--src/kernel/proc.c8
2 files changed, 6 insertions, 7 deletions
diff --git a/src/kernel/main.c b/src/kernel/main.c
index 14514cb..a0fdd07 100644
--- a/src/kernel/main.c
+++ b/src/kernel/main.c
@@ -28,10 +28,5 @@ void shutdown(void) {
kprintf("state 0x%x: 0x%x\n", i, states[i]);
mem_debugprint();
-
- // TODO generalize to process_cleanup
- process_free(process_first);
-
- mem_debugprint();
cpu_shutdown();
}
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;