diff options
| author | Kacper <kacper@mail.openlinux.dev> | 2025-12-07 20:10:31 +0100 |
|---|---|---|
| committer | Kacper <kacper@mail.openlinux.dev> | 2025-12-07 20:10:31 +0100 |
| commit | fc00c656c96528112d05cf0edf8631bd5eaea446 (patch) | |
| tree | a6e0e6c588191a8bd1c64afc3b7a258e3e66c236 /lib/libc/stdlib/abort.c | |
Add build system scaffolding and libc headers
Diffstat (limited to 'lib/libc/stdlib/abort.c')
| -rw-r--r-- | lib/libc/stdlib/abort.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/libc/stdlib/abort.c b/lib/libc/stdlib/abort.c new file mode 100644 index 00000000..3d022e70 --- /dev/null +++ b/lib/libc/stdlib/abort.c @@ -0,0 +1,27 @@ +#include <atomic.h> +#include <stdlib.h> +#include <syscall.h> +#include <asm-generic/signal.h> +#include <thread.h> +#include <threads.h> +#include <unistd.h> +#include <libc.h> + +int raise(int); + +_Noreturn void abort(void) +{ + struct sigaction sa; + + raise(SIGABRT); + + LIBC_LOCK(libc.lock.abort); + sa.sa_handler = SIG_DFL; + + __syscall(rt_sigaction, SIGABRT, &sa, NULL, _NSIG / 8); + __syscall(tkill, thrd_current()->tid, SIGABRT); + + // This point should never be reached + raise(SIGKILL); + _exit(127); +} |
