feat: add process termination codes and SYS_ABORT; whole-process abort() from any thread in libc and montauk-rt

This commit is contained in:
daniel committed 2026-10-14 07:32:15 +02:00
1 parent f8b8f9610f
commit 278b208258
15 files changed
+126 -37

No files matched your search

+5 -4
View File
@@ -130,6 +130,7 @@ static inline long _mtk_syscall4(long nr, long a1, long a2, long a3, long a4) {
#define SYS_GETENVIRON 171
#define SYS_SETENVIRON 172
#define SYS_SPAWN_ENV 173
#define SYS_ABORT 198
/* ========================================================================
errno
@@ -1243,9 +1244,9 @@ void exit(int status) {
__builtin_unreachable();
}
/* Ends the whole process from any thread; waitpid sees WTERMSIG == SIGABRT. */
void abort(void) {
_mtk_syscall1(SYS_PRINT, (long)"abort() called\n");
_mtk_syscall1(SYS_EXIT, 1);
_mtk_syscall0(SYS_ABORT);
__builtin_unreachable();
}
@@ -4055,8 +4056,8 @@ pid_t waitpid(pid_t pid, int *status, int options) {
}
long code = _mtk_syscall1(SYS_WAITPID, (long)pid);
if (status != NULL) {
if (code >= 256) {
*status = (int)((code - 256) & 0x7F); /* signaled */
if (code >= TerminationBase) {
*status = (int)((code - TerminationBase) & 0x7F); /* signaled */
} else {
*status = (int)((code & 0xFF) << 8); /* exited */
}