From cf15b874e8c9a0824f9425244b068ea7a4fa5fc8 Mon Sep 17 00:00:00 2001 From: Reid Spencer Date: Mon, 27 Dec 2004 06:17:27 +0000 Subject: For PR351: * Move implementation of sys::PreventCoreFiles function to this file from the now defunct SysConfig abstraction. llvm-svn: 19159 --- llvm/lib/System/Unix/Process.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'llvm/lib/System/Unix/Process.cpp') diff --git a/llvm/lib/System/Unix/Process.cpp b/llvm/lib/System/Unix/Process.cpp index 1c203ab50c5..19533905175 100644 --- a/llvm/lib/System/Unix/Process.cpp +++ b/llvm/lib/System/Unix/Process.cpp @@ -109,6 +109,18 @@ Process::GetTimeUsage(TimeValue& elapsed, TimeValue& user_time, #endif } +// Some LLVM programs such as bugpoint produce core files as a normal part of +// their operation. To prevent the disk from filling up, this function +// does what's necessary to prevent their generation. +void Process::PreventCoreFiles() { +#if HAVE_SETRLIMIT + struct rlimit rlim; + rlim.rlim_cur = rlim.rlim_max = 0; + int res = setrlimit(RLIMIT_CORE, &rlim); + if (res != 0) + ThrowErrno("Can't prevent core file generation"); +#endif +} } // vim: sw=2 smartindent smarttab tw=80 autoindent expandtab -- cgit v1.2.3