Reid Spencer | 387e5ec | 2004-08-31 17:43:29 +0000 | [diff] [blame] | 1 | //===- SysConfig.cpp - Generic UNIX System Configuration --------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file was developed by Reid Spencer and is distributed under the |
| 6 | // University of Illinois Open Source License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file defines some functions for managing system configuration on Unix |
| 11 | // systems. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
| 15 | #include "Unix.h" |
| 16 | #include <sys/resource.h> |
| 17 | |
| 18 | namespace llvm { |
Reid Spencer | 387e5ec | 2004-08-31 17:43:29 +0000 | [diff] [blame] | 19 | |
| 20 | // Some LLVM programs such as bugpoint produce core files as a normal part of |
| 21 | // their operation. To prevent the disk from filling up, this configuration item |
| 22 | // does what's necessary to prevent their generation. |
Reid Spencer | ef6efab | 2004-08-31 17:53:41 +0000 | [diff] [blame] | 23 | void sys::PreventCoreFiles() { |
Reid Spencer | 387e5ec | 2004-08-31 17:43:29 +0000 | [diff] [blame] | 24 | struct rlimit rlim; |
| 25 | rlim.rlim_cur = rlim.rlim_max = 0; |
| 26 | int res = setrlimit(RLIMIT_CORE, &rlim); |
| 27 | if (res != 0) |
| 28 | ThrowErrno("Can't prevent core file generation"); |
| 29 | } |
| 30 | |
| 31 | } |
| 32 | |
| 33 | // vim: sw=2 smartindent smarttab tw=80 autoindent expandtab |