xref: /aosp_15_r20/external/llvm/lib/Support/Unix/Watchdog.inc (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker//===--- Unix/Watchdog.inc - Unix Watchdog Implementation -------*- C++ -*-===//
2*9880d681SAndroid Build Coastguard Worker//
3*9880d681SAndroid Build Coastguard Worker//                     The LLVM Compiler Infrastructure
4*9880d681SAndroid Build Coastguard Worker//
5*9880d681SAndroid Build Coastguard Worker// This file is distributed under the University of Illinois Open Source
6*9880d681SAndroid Build Coastguard Worker// License. See LICENSE.TXT for details.
7*9880d681SAndroid Build Coastguard Worker//
8*9880d681SAndroid Build Coastguard Worker//===----------------------------------------------------------------------===//
9*9880d681SAndroid Build Coastguard Worker//
10*9880d681SAndroid Build Coastguard Worker// This file provides the generic Unix implementation of the Watchdog class.
11*9880d681SAndroid Build Coastguard Worker//
12*9880d681SAndroid Build Coastguard Worker//===----------------------------------------------------------------------===//
13*9880d681SAndroid Build Coastguard Worker
14*9880d681SAndroid Build Coastguard Worker#ifdef HAVE_UNISTD_H
15*9880d681SAndroid Build Coastguard Worker#include <unistd.h>
16*9880d681SAndroid Build Coastguard Worker#endif
17*9880d681SAndroid Build Coastguard Worker
18*9880d681SAndroid Build Coastguard Workernamespace llvm {
19*9880d681SAndroid Build Coastguard Worker  namespace sys {
20*9880d681SAndroid Build Coastguard Worker    Watchdog::Watchdog(unsigned int seconds) {
21*9880d681SAndroid Build Coastguard Worker#ifdef HAVE_UNISTD_H
22*9880d681SAndroid Build Coastguard Worker      alarm(seconds);
23*9880d681SAndroid Build Coastguard Worker#endif
24*9880d681SAndroid Build Coastguard Worker    }
25*9880d681SAndroid Build Coastguard Worker
26*9880d681SAndroid Build Coastguard Worker    Watchdog::~Watchdog() {
27*9880d681SAndroid Build Coastguard Worker#ifdef HAVE_UNISTD_H
28*9880d681SAndroid Build Coastguard Worker      alarm(0);
29*9880d681SAndroid Build Coastguard Worker#endif
30*9880d681SAndroid Build Coastguard Worker    }
31*9880d681SAndroid Build Coastguard Worker  }
32*9880d681SAndroid Build Coastguard Worker}
33