From 9f9f4d4e3fd813e4a640e64693f6913d710853ef Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Sun, 21 May 2017 22:20:28 +0200 Subject: [PATCH] Print an kernel error rather than panicing if init(8) exits abnormally. This avoids the misimpression that a kernel bug happened and it avoids clearing the screen of potentially useful information about an init(8) crash. --- init/init.8 | 6 ++++-- kernel/kernel.cpp | 5 ++++- share/man/man7/kernel.7 | 5 ++++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/init/init.8 b/init/init.8 index 2649bed8..fe691148 100644 --- a/init/init.8 +++ b/init/init.8 @@ -218,10 +218,12 @@ graphics resolution (see .Sh EXIT STATUS .Nm exits 0 if the kernel should power off, exits 1 if the kernel should reboot, or -exits 2 if the boot failed and the kernel should halt. +exits 2 if the boot failed and the kernel should halt with a complaint about an +.Nm +fatality. Any other exit by the initial .Nm -will trigger a kernel panic. +will cause the kernel to halt with a complaint about an unexpected exit code. .Nm exits with the same exit status as its target session if it terminates normally. .Sh SEE ALSO diff --git a/kernel/kernel.cpp b/kernel/kernel.cpp index 8cefd171..62891a07 100644 --- a/kernel/kernel.cpp +++ b/kernel/kernel.cpp @@ -666,7 +666,10 @@ static void BootThread(void* /*user*/) Log::Sync(); HaltKernel(); default: - PanicF("Init returned with unexpected return code %i", status); + Log::PrintF("kernel: fatal: init exited with unexpected exit code %i\n", + status); + Log::Sync(); + HaltKernel(); } } diff --git a/share/man/man7/kernel.7 b/share/man/man7/kernel.7 index e2339cb4..3abdc973 100644 --- a/share/man/man7/kernel.7 +++ b/share/man/man7/kernel.7 @@ -39,7 +39,10 @@ delimiter to stop kernel option parsing. The computer is powered off if the .Nm init process exits 0, rebooted if it exits 1, -halted if it exits 2, and paniced otherwise. +halted with an complaint about an +.Nm init +fatality if it exits 2, and halted with a complaint about an unexpected exit code +otherwise. .Pp The options are as follows: .Bl -tag -width "12345678"