summaryrefslogtreecommitdiff
path: root/lib/libc/stdlib/abort.c
blob: 3d022e7078b90e74906c09b1f811453477e0533b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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);
}