Watchdog.inc 839 B

123456789101112131415161718192021222324252627282930313233
  1. //===--- Unix/Watchdog.inc - Unix Watchdog Implementation -------*- C++ -*-===//
  2. //
  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
  6. //
  7. //===----------------------------------------------------------------------===//
  8. //
  9. // This file provides the generic Unix implementation of the Watchdog class.
  10. //
  11. //===----------------------------------------------------------------------===//
  12. #include "llvm/Config/config.h"
  13. #ifdef HAVE_UNISTD_H
  14. #include <unistd.h>
  15. #endif
  16. namespace llvm {
  17. namespace sys {
  18. Watchdog::Watchdog(unsigned int seconds) {
  19. #ifdef HAVE_UNISTD_H
  20. alarm(seconds);
  21. #endif
  22. }
  23. Watchdog::~Watchdog() {
  24. #ifdef HAVE_UNISTD_H
  25. alarm(0);
  26. #endif
  27. }
  28. }
  29. }