blob: b363ef7795603924508e15f826ff112101089bea [file] [log] [blame]
Nick Lewycky4e06def2013-03-26 01:27:52 +00001//===--- Unix/Watchdog.inc - Unix Watchdog Implementation -------*- C++ -*-===//
2//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// 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 Lewycky4e06def2013-03-26 01:27:52 +00006//
7//===----------------------------------------------------------------------===//
8//
9// This file provides the generic Unix implementation of the Watchdog class.
10//
11//===----------------------------------------------------------------------===//
12
Nico Weber432a3882018-04-30 14:59:11 +000013#include "llvm/Config/config.h"
14
Nick Lewycky4e06def2013-03-26 01:27:52 +000015#ifdef HAVE_UNISTD_H
16#include <unistd.h>
17#endif
18
19namespace 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 Kornienkof00654e2015-06-23 09:49:53 +000032 }
33}