| //===--- Shutdown.cpp - Unclean exit scenarios ----------------------------===// |
| // 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 "support/Shutdown.h" |
| void abortAfterTimeout(std::chrono::seconds Timeout) { |
| // This is more portable than sys::WatchDog, and yields a stack trace. |
| std::this_thread::sleep_for(Timeout); |
| static std::atomic<bool> ShutdownRequested = {false}; |
| if (ShutdownRequested.exchange(true)) |
| // This is the second shutdown request. Exit hard. |
| bool shutdownRequested() { return ShutdownRequested; } |