1//===-- Implementation of abort -------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#include "src/__support/common.h"
10#include "src/signal/raise.h"
11#include "src/stdlib/_Exit.h"
12
13#include "src/stdlib/abort.h"
14
15namespace LIBC_NAMESPACE {
16
17LLVM_LIBC_FUNCTION(void, abort, ()) {
18 // TODO: When sigprocmask and sigaction land:
19 // Unblock SIGABRT, raise it, if it was ignored or the handler returned,
20 // change its action to SIG_DFL, raise it again.
21 // TODO: When C11 mutexes land:
22 // Acquire recursive mutex (in case the current signal handler for SIGABRT
23 // itself calls abort we don't want to deadlock on the same thread trying
24 // to acquire it's own mutex.)
25 LIBC_NAMESPACE::raise(SIGABRT);
26 LIBC_NAMESPACE::raise(SIGKILL);
27 LIBC_NAMESPACE::_Exit(status: 127);
28}
29
30} // namespace LIBC_NAMESPACE
31

source code of libc/src/stdlib/linux/abort.cpp