From 4e06def851a32cbe1a7d18562462850cb9ca2a1e Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Tue, 26 Mar 2013 01:27:52 +0000 Subject: Add a new watchdog timer interface. The interface does not permit handling timeouts, so it's only really useful if you're going to crash anyways. Use it in the pretty stack trace printer to kill the compiler if we hang while printing the stack trace. llvm-svn: 177962 --- llvm/lib/Support/Unix/Watchdog.inc | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 llvm/lib/Support/Unix/Watchdog.inc (limited to 'llvm/lib/Support/Unix') diff --git a/llvm/lib/Support/Unix/Watchdog.inc b/llvm/lib/Support/Unix/Watchdog.inc new file mode 100644 index 00000000000..5d89c0e51b1 --- /dev/null +++ b/llvm/lib/Support/Unix/Watchdog.inc @@ -0,0 +1,32 @@ +//===--- Unix/Watchdog.inc - Unix Watchdog Implementation -------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file provides the generic Unix implementation of the Watchdog class. +// +//===----------------------------------------------------------------------===// + +#ifdef HAVE_UNISTD_H +#include +#endif + +namespace llvm { + namespace sys { + Watchdog::Watchdog(unsigned int seconds) { +#ifdef HAVE_UNISTD_H + alarm(seconds); +#endif + } + + Watchdog::~Watchdog() { +#ifdef HAVE_UNISTD_H + alarm(0); +#endif + } + } +} -- cgit v1.2.3