mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-20 01:37:39 +03: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:
parent
a25cc9619d
commit
70ccdb300b
Notes:
sideshowbarker
2024-07-17 17:42:07 +09:00
Author: https://github.com/BertalanD Commit: https://github.com/SerenityOS/serenity/commit/70ccdb300b Pull-request: https://github.com/SerenityOS/serenity/pull/12886 Reviewed-by: https://github.com/ADKaster Reviewed-by: https://github.com/linusg ✅
@ -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();
|
||||
|
@ -97,6 +97,8 @@ extern "C" [[noreturn]] void init(BootInfo const&);
|
||||
|
||||
READONLY_AFTER_INIT VirtualConsole* tty0;
|
||||
|
||||
ProcessID g_init_pid { 0 };
|
||||
|
||||
static Processor s_bsp_processor; // global but let's keep it "private"
|
||||
|
||||
// SerenityOS Kernel C++ entry point :^)
|
||||
@ -374,6 +376,8 @@ void init_stage2(void*)
|
||||
if (init_or_error.is_error())
|
||||
PANIC("init_stage2: Error spawning init process: {}", init_or_error.error());
|
||||
|
||||
g_init_pid = init_or_error.value()->pid();
|
||||
|
||||
thread->set_priority(THREAD_PRIORITY_HIGH);
|
||||
|
||||
if (boot_profiling) {
|
||||
|
Loading…
Reference in New Issue
Block a user