summaryrefslogtreecommitdiff
path: root/Kernel/Process.cpp
diff options
context:
space:
mode:
authorDaniel Bertalan <dani@danielbertalan.dev>2022-03-05 21:01:06 +0100
committerLinus Groh <mail@linusgroh.de>2022-03-08 23:30:47 +0100
commit70ccdb300bdfb20d465f7e1933f719b707e0f924 (patch)
tree62b472db0f3cfaeb07d1d80a1bea1193e4d75014 /Kernel/Process.cpp
parenta25cc9619d7dfd8e5ec3c4ed12f7abc975ce2f6f (diff)
downloadserenity-70ccdb300bdfb20d465f7e1933f719b707e0f924.zip
Kernel: Panic if the init process dies
If init crashes, all other userspace processes exit too, thus rendering the system unusable. Previously, the kernel would still keep running even without a userland, showing just a black screen without any indication of the issue. We now panic the kernel, which shows a message on the console. In the case of the CI runners, it shuts down the virtual machine, so we don't have to wait for the 1 hour timeout if an issue arises with SystemServer.
Diffstat (limited to 'Kernel/Process.cpp')
-rw-r--r--Kernel/Process.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp
index aede604637..135e7ebcb8 100644
--- a/Kernel/Process.cpp
+++ b/Kernel/Process.cpp
@@ -26,6 +26,7 @@
#include <Kernel/Memory/AnonymousVMObject.h>
#include <Kernel/Memory/PageDirectory.h>
#include <Kernel/Memory/SharedInodeVMObject.h>
+#include <Kernel/Panic.h>
#include <Kernel/PerformanceEventBuffer.h>
#include <Kernel/PerformanceManager.h>
#include <Kernel/Process.h>
@@ -42,6 +43,8 @@ namespace Kernel {
static void create_signal_trampoline();
+extern ProcessID g_init_pid;
+
RecursiveSpinlock g_profiling_lock;
static Atomic<pid_t> next_pid;
static Singleton<SpinlockProtected<Process::List>> s_all_instances;
@@ -609,6 +612,9 @@ void Process::finalize()
if (veil_state() == VeilState::Dropped)
dbgln("\x1b[01;31mProcess '{}' exited with the veil left open\x1b[0m", name());
+ if (g_init_pid != 0 && pid() == g_init_pid)
+ PANIC("Init process quit unexpectedly. Exit code: {}", m_protected_values.termination_status);
+
if (is_dumpable()) {
if (m_should_generate_coredump) {
auto result = dump_core();