feat: add process termination codes and SYS_ABORT; whole-process abort() from any thread in libc and montauk-rt
This commit is contained in:
1 parent
f8b8f9610f
commit
278b208258
15 files changed
+126
-37
No files matched your search
@@ -8,6 +8,7 @@
|
||||
|
||||
#include <Memory/Heap.hpp>
|
||||
#include <Common/Panic.hpp>
|
||||
#include <Common/TerminationCodes.hpp>
|
||||
#include <Platform/Registers.hpp>
|
||||
#include <CppLib/Stream.hpp>
|
||||
#include <Memory/PageFrameAllocator.hpp>
|
||||
@@ -170,23 +171,20 @@ namespace Hal {
|
||||
CrashReport::AddReport(rep);
|
||||
Sched::SpawnCrashPad(proc->pid);
|
||||
|
||||
// Record a killed-by-signal exit code (256+sig) so a parent
|
||||
// blocked in SYS_WAITPID can tell a crash from a clean exit.
|
||||
// Record a termination code (256+sig) so a parent blocked in
|
||||
// SYS_WAITPID can tell a crash from a clean exit.
|
||||
{
|
||||
int sig = 11; /* SIGSEGV */
|
||||
if (i == 0x00) sig = 8; /* #DE -> SIGFPE */
|
||||
else if (i == 0x06) sig = 4; /* #UD -> SIGILL */
|
||||
else if (i == 0x10 || i == 0x13) sig = 8; /* x87/SIMD FP */
|
||||
int code = TerminationFromVector(i);
|
||||
|
||||
// ExitProcess from a sibling thread ends only that thread,
|
||||
// which would leave the process running with the crash
|
||||
// swallowed. Flag the whole process (main thread and every
|
||||
// sibling) first, carrying the crash code rather than
|
||||
// KillProcess's default SIGKILL, so waiters see the fault.
|
||||
// KillProcess's default TerminatedKilled, so waiters see the fault.
|
||||
if (Sched::GetCurrentThreadPtr() != proc) {
|
||||
Sched::KillProcess(proc->pid, 256 + sig);
|
||||
Sched::KillProcess(proc->pid, code);
|
||||
} else {
|
||||
Sched::SetProcessExitCode(proc->pid, 256 + sig);
|
||||
Sched::SetProcessExitCode(proc->pid, code);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user