Kill usermode process on exceptions.
This commit is contained in:
parent
e8845b5012
commit
4c71e65cc5
@ -105,6 +105,13 @@ void trap(registers_t *r) {
|
|||||||
if (r->int_no < ARRLEN(exception_messages)) {
|
if (r->int_no < ARRLEN(exception_messages)) {
|
||||||
msg = exception_messages[r->int_no];
|
msg = exception_messages[r->int_no];
|
||||||
}
|
}
|
||||||
|
if (r->cs & 3) {
|
||||||
|
// exception from user mode, kill offending process
|
||||||
|
printk("Exception: ");
|
||||||
|
printk(msg);
|
||||||
|
printk("\n");
|
||||||
|
killproc();
|
||||||
|
}
|
||||||
panic(msg);
|
panic(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
1
proc.c
1
proc.c
@ -82,6 +82,7 @@ _Noreturn void killproc() {
|
|||||||
void* task_stack;
|
void* task_stack;
|
||||||
switchkvm();
|
switchkvm();
|
||||||
freevm(vm.user_task->pgdir);
|
freevm(vm.user_task->pgdir);
|
||||||
|
sti();
|
||||||
swtch(&task_stack, vm.kernel_thread);
|
swtch(&task_stack, vm.kernel_thread);
|
||||||
__builtin_unreachable();
|
__builtin_unreachable();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user