libc: Rewrite abort() using the new signals
Some checks failed
continuous-integration/drone/pr Build is failing
Some checks failed
continuous-integration/drone/pr Build is failing
This commit is contained in:
parent
8066e8f1d8
commit
3df40beaf2
@ -6,6 +6,7 @@
|
|||||||
#include <luna/NumberParsing.h>
|
#include <luna/NumberParsing.h>
|
||||||
#include <luna/Sort.h>
|
#include <luna/Sort.h>
|
||||||
#include <luna/Utf8.h>
|
#include <luna/Utf8.h>
|
||||||
|
#include <signal.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
@ -99,7 +100,25 @@ extern "C"
|
|||||||
|
|
||||||
__noreturn void abort()
|
__noreturn void abort()
|
||||||
{
|
{
|
||||||
syscall(SYS_exit, 255);
|
// First, try to unblock SIGABRT and then raise it.
|
||||||
|
sigset_t set;
|
||||||
|
sigemptyset(&set);
|
||||||
|
sigaddset(&set, SIGABRT);
|
||||||
|
sigprocmask(SIG_UNBLOCK, &set, nullptr);
|
||||||
|
|
||||||
|
raise(SIGABRT);
|
||||||
|
|
||||||
|
// Still here? The program must have catched it. Reset the disposition to default.
|
||||||
|
struct sigaction act;
|
||||||
|
act.sa_handler = SIG_DFL;
|
||||||
|
sigemptyset(&act.sa_mask);
|
||||||
|
act.sa_flags = 0;
|
||||||
|
sigaction(SIGABRT, &act, nullptr);
|
||||||
|
|
||||||
|
raise(SIGABRT);
|
||||||
|
|
||||||
|
// There is no way we could end up here, unless there is some sort of race condition or the kernel decided to
|
||||||
|
// change the default action for SIGABRT because it's a Tuesday.
|
||||||
__builtin_unreachable();
|
__builtin_unreachable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user