aboutsummaryrefslogtreecommitdiff
path: root/kernel/features
diff options
context:
space:
mode:
authorMarvin Borner2020-09-06 00:02:41 +0200
committerMarvin Borner2020-09-06 00:02:41 +0200
commitc0608f199fc711aa82867f80059dfeebf38b4a25 (patch)
tree2495344b5910bf5f1c2977fc829b715ca320ffb3 /kernel/features
parentb00d78697723eb3930a40125c02d328548946206 (diff)
Fixed GPF on non-existent exec
Diffstat (limited to 'kernel/features')
-rw-r--r--kernel/features/proc.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/kernel/features/proc.c b/kernel/features/proc.c
index 438ded7..a5df875 100644
--- a/kernel/features/proc.c
+++ b/kernel/features/proc.c
@@ -70,7 +70,7 @@ void proc_print()
struct proc *proc_current()
{
- return current ? current->data : NULL;
+ return current && current->data ? current->data : NULL;
}
void proc_send(struct proc *src, struct proc *dest, enum message_type type, void *data)
@@ -111,19 +111,24 @@ struct proc *proc_from_pid(u32 pid)
void proc_exit(struct proc *proc, int status)
{
assert(proc);
- printf("Process %s exited with status %d\n", proc->name, status);
+ int res = 0;
struct node *iterator = proc_list->head;
do {
if (iterator->data == proc) {
+ res = 1;
list_remove(proc_list, iterator);
break;
}
} while ((iterator = iterator->next) != NULL);
+ if (memcmp(proc, current->data, sizeof(*proc)) == 0)
+ current = NULL;
+
+ if (res)
+ printf("Process %s exited with status %d\n", proc->name, status);
+
quantum = 0; // TODO: Add quantum to each process struct?
- sti();
- hlt();
}
void proc_yield(struct regs *r)