1 //===--- Shutdown.cpp - Unclean exit scenarios ----------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 #include "support/Shutdown.h"
18 void abortAfterTimeout(std::chrono::seconds Timeout
) {
19 // This is more portable than sys::WatchDog, and yields a stack trace.
20 std::thread([Timeout
] {
21 std::this_thread::sleep_for(Timeout
);
26 static std::atomic
<bool> ShutdownRequested
= {false};
28 void requestShutdown() {
29 if (ShutdownRequested
.exchange(true))
30 // This is the second shutdown request. Exit hard.
34 bool shutdownRequested() { return ShutdownRequested
; }