summaryrefslogtreecommitdiff
path: root/lib/System/Unix/Process.inc
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-09-14 06:01:41 +0000
committerChris Lattner <sabre@nondot.org>2006-09-14 06:01:41 +0000
commit26b6c0ba5da19390e9584fb8b533a941f6adb6c6 (patch)
treeaa06411e90914572e168f9e0962ebb4cd87b2e96 /lib/System/Unix/Process.inc
parent9abd7c38675ad305c733b7e90578255271afc6bd (diff)
downloadllvm-26b6c0ba5da19390e9584fb8b533a941f6adb6c6.tar.gz
llvm-26b6c0ba5da19390e9584fb8b533a941f6adb6c6.tar.bz2
llvm-26b6c0ba5da19390e9584fb8b533a941f6adb6c6.tar.xz
On Mac OS/X, make Process::PreventCoreFiles disable crash reporter for
the process in addition to disabling core file emission. This speeds up bugpoint on default-configured macs by several orders of magnitude. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30317 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/System/Unix/Process.inc')
-rw-r--r--lib/System/Unix/Process.inc36
1 files changed, 29 insertions, 7 deletions
diff --git a/lib/System/Unix/Process.inc b/lib/System/Unix/Process.inc
index 0d79ad9bee..bcabf5f140 100644
--- a/lib/System/Unix/Process.inc
+++ b/lib/System/Unix/Process.inc
@@ -30,7 +30,7 @@
//=== is guaranteed to work on *all* UNIX variants.
//===----------------------------------------------------------------------===//
-namespace llvm {
+using namespace llvm;
using namespace sys;
unsigned
@@ -115,16 +115,18 @@ Process::GetTimeUsage(TimeValue& elapsed, TimeValue& user_time,
#endif
}
-int Process::GetCurrentUserId()
-{
+int Process::GetCurrentUserId() {
return getuid();
}
-int Process::GetCurrentGroupId()
-{
+int Process::GetCurrentGroupId() {
return getgid();
}
+#ifdef __APPLE__ // FIXME: Should be configurified.
+#include <mach/mach.h>
+#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.
@@ -134,6 +136,28 @@ void Process::PreventCoreFiles() {
rlim.rlim_cur = rlim.rlim_max = 0;
setrlimit(RLIMIT_CORE, &rlim);
#endif
+
+#ifdef __APPLE__ // FIXME: Should be configurified.
+ // Disable crash reporting on Mac OS/X.
+
+ // get information about the original set of exception ports for the task
+ mach_msg_type_number_t Count = 0;
+ exception_mask_t OriginalMasks[EXC_TYPES_COUNT];
+ exception_port_t OriginalPorts[EXC_TYPES_COUNT];
+ exception_behavior_t OriginalBehaviors[EXC_TYPES_COUNT];
+ thread_state_flavor_t OriginalFlavors[EXC_TYPES_COUNT];
+ kern_return_t err =
+ task_get_exception_ports(mach_task_self(), EXC_MASK_ALL, OriginalMasks,
+ &Count, OriginalPorts, OriginalBehaviors,
+ OriginalFlavors);
+ if (err == KERN_SUCCESS) {
+ // replace each with MACH_PORT_NULL.
+ for (unsigned i = 0; i != Count; ++i)
+ task_set_exception_ports(mach_task_self(), OriginalMasks[i],
+ MACH_PORT_NULL, OriginalBehaviors[i],
+ OriginalFlavors[i]);
+ }
+#endif
}
bool Process::StandardInIsUserInput() {
@@ -159,5 +183,3 @@ bool Process::StandardErrIsDisplayed() {
// If we don't have isatty, just return false.
return false;
}
-
-}