Nick Lewycky | 4e06def | 2013-03-26 01:27:52 +0000 | [diff] [blame] | 1 | //===--- Unix/Watchdog.inc - Unix Watchdog Implementation -------*- C++ -*-===// |
| 2 | // |
Chandler Carruth | 2946cd7 | 2019-01-19 08:50:56 +0000 | [diff] [blame] | 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 |
Nick Lewycky | 4e06def | 2013-03-26 01:27:52 +0000 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | // |
| 9 | // This file provides the generic Unix implementation of the Watchdog class. |
| 10 | // |
| 11 | //===----------------------------------------------------------------------===// |
| 12 | |
Nico Weber | 432a388 | 2018-04-30 14:59:11 +0000 | [diff] [blame] | 13 | #include "llvm/Config/config.h" |
| 14 | |
Nick Lewycky | 4e06def | 2013-03-26 01:27:52 +0000 | [diff] [blame] | 15 | #ifdef HAVE_UNISTD_H |
| 16 | #include <unistd.h> |
| 17 | #endif |
| 18 | |
| 19 | namespace llvm { |
| 20 | namespace sys { |
| 21 | Watchdog::Watchdog(unsigned int seconds) { |
| 22 | #ifdef HAVE_UNISTD_H |
| 23 | alarm(seconds); |
| 24 | #endif |
| 25 | } |
| 26 | |
| 27 | Watchdog::~Watchdog() { |
| 28 | #ifdef HAVE_UNISTD_H |
| 29 | alarm(0); |
| 30 | #endif |
| 31 | } |
Alexander Kornienko | f00654e | 2015-06-23 09:49:53 +0000 | [diff] [blame] | 32 | } |
| 33 | } |