1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 20:17:44 +00:00

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.
This commit is contained in:
Daniel Bertalan 2022-03-05 21:01:06 +01:00 committed by Linus Groh
parent a25cc9619d
commit 70ccdb300b
2 changed files with 10 additions and 0 deletions

View file

@ -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();