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
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* TerminationCodes.hpp
|
||||
* MontaukOS process termination codes.
|
||||
* Copyright (c) 2026 Daniel Hammer
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
// Exit code recorded when the kernel ends a process, as opposed to the
|
||||
// process calling SYS_EXIT (which is masked to 0..255). Encoded as
|
||||
// 256 + POSIX signal number so libc waitpid can report WTERMSIG.
|
||||
// Mirrored in userspace at programs/include/montauk/statuscodes.h.
|
||||
enum TerminationCodes {
|
||||
TerminationBase = 256,
|
||||
TerminatedIllegalInstruction = TerminationBase + 4, // SIGILL
|
||||
TerminatedBreakpoint = TerminationBase + 5, // SIGTRAP
|
||||
TerminatedAborted = TerminationBase + 6, // SIGABRT
|
||||
TerminatedArithmeticError = TerminationBase + 8, // SIGFPE
|
||||
TerminatedKilled = TerminationBase + 9, // SIGKILL
|
||||
TerminatedAccessViolation = TerminationBase + 11 // SIGSEGV
|
||||
};
|
||||
|
||||
// Termination code for a user-mode CPU exception. The exact vector is
|
||||
// kept in the crash report; this is only the category.
|
||||
inline TerminationCodes TerminationFromVector(uint8_t vector) {
|
||||
switch (vector) {
|
||||
case 0x06: return TerminatedIllegalInstruction; // #UD
|
||||
case 0x01: // #DB
|
||||
case 0x03: return TerminatedBreakpoint; // #BP
|
||||
case 0x00: // #DE
|
||||
case 0x10: // #MF
|
||||
case 0x13: return TerminatedArithmeticError; // #XM
|
||||
default: return TerminatedAccessViolation; // #PF, #GP, #SS, #NP, #AC, #OF, #BR, #CP, ...
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user