aboutsummaryrefslogtreecommitdiff
path: root/libc/src/stdlib/linux/abort.cpp
blob: 59feec3e5a06df3aaf11a1ae8be8ae40856080cd (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
28
29
30
//===-- Implementation of abort -------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "src/__support/common.h"
#include "src/signal/raise.h"
#include "src/stdlib/_Exit.h"

#include "src/stdlib/abort.h"

namespace LIBC_NAMESPACE {

LLVM_LIBC_FUNCTION(void, abort, ()) {
  // TODO: When sigprocmask and sigaction land:
  // Unblock SIGABRT, raise it, if it was ignored or the handler returned,
  // change its action to SIG_DFL, raise it again.
  // TODO: When C11 mutexes land:
  // Acquire recursive mutex (in case the current signal handler for SIGABRT
  // itself calls abort we don't want to deadlock on the same thread trying
  // to acquire it's own mutex.)
  LIBC_NAMESPACE::raise(SIGABRT);
  LIBC_NAMESPACE::raise(SIGKILL);
  LIBC_NAMESPACE::_Exit(127);
}

} // namespace LIBC_NAMESPACE