summaryrefslogtreecommitdiff
path: root/Kernel/Task.cpp
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2018-10-22 11:43:55 +0200
committerAndreas Kling <awesomekling@gmail.com>2018-10-22 11:43:55 +0200
commit3a3c57357c95629dc89c1045c7dbe3b0c1c6c778 (patch)
tree33fee3c22d29290280b1f73df74c8f1995ef2899 /Kernel/Task.cpp
parent79ffdb720564bea95d753f6ebe7815fa0ada3501 (diff)
downloadserenity-3a3c57357c95629dc89c1045c7dbe3b0c1c6c778.zip
Add a sys$exit and make init_stage2 call it when finished.
Diffstat (limited to 'Kernel/Task.cpp')
-rw-r--r--Kernel/Task.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/Kernel/Task.cpp b/Kernel/Task.cpp
index 581345a669..e46985ee4b 100644
--- a/Kernel/Task.cpp
+++ b/Kernel/Task.cpp
@@ -235,6 +235,26 @@ void Task::dumpRegions()
}
}
+void Task::sys$exit(int status)
+{
+ cli();
+ kprintf("sys$exit: %s(%u) exit with status %d\n", name().characters(), pid(), status);
+
+ setState(Exiting);
+ dumpRegions();
+
+ s_tasks->remove(this);
+
+ if (!scheduleNewTask()) {
+ kprintf("Task::taskDidCrash: Failed to schedule a new task :(\n");
+ HANG;
+ }
+
+ delete this;
+
+ switchNow();
+}
+
void Task::taskDidCrash(Task* crashedTask)
{
// NOTE: This is called from an excepton handler, so interrupts are disabled.