From 80bd3b6a7b86c26b4b26bc6d922a09957ddb79ac Mon Sep 17 00:00:00 2001 From: Richard Frith-MacDonald Date: Fri, 15 Mar 2013 11:02:32 +0000 Subject: [PATCH] Improve core dump setting git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/ec/trunk@36362 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 6 ++++++ EcProcess.h | 7 +++++++ EcProcess.m | 50 +++++++++++++++++++++++++++----------------------- 3 files changed, 40 insertions(+), 23 deletions(-) diff --git a/ChangeLog b/ChangeLog index fab74d4..a436c7f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2013-03-15 Richard Frith-Macdonald + + * EcProcess.h: Document EcCoreSize + * EcProcess.m: Change so that if no value is set, we don't use any + limit, and so that if a negative value is set we use 1GB + 2013-03-13 Richard Frith-Macdonald * GNUmakefile: 1.0.2 release diff --git a/EcProcess.h b/EcProcess.h index f65f476..612fb6b 100644 --- a/EcProcess.h +++ b/EcProcess.h @@ -50,6 +50,13 @@ startup settings + EcCoreSize + + Specifies the maximum size (in bytes) for any core-dump of the + process. + If this is negative, the default size of 1GB is used.
+ If this is zero (or no value is set) then no limit is set. +
EcDebug- Any key of the form EcDebug-xxx turns on the xxx debug level diff --git a/EcProcess.m b/EcProcess.m index 401c4f7..09f3ce3 100644 --- a/EcProcess.m +++ b/EcProcess.m @@ -3109,32 +3109,36 @@ NSLog(@"Ignored attempt to set timer interval to %g ... using 10.0", interval); } } - i = [cmdDefs integerForKey: @"CoreSize"]; - if (i <= 0) + if (i < 0) { - i = 250000000; - } - if (getrlimit(RLIMIT_CORE, &rlim) < 0) - { - NSLog(@"Unable to get core file size limit: %d", errno); - } - else - { - if (rlim.rlim_max < i) - { - NSLog(@"Hard limit for core file size (%lu) less than desired", - rlim.rlim_max); - } - else - { - rlim.rlim_cur = i; - if (setrlimit(RLIMIT_CORE, &rlim) < 0) - { - NSLog(@"Unable to set core file size limit: %d", errno); - } - } + i = 1024 * 1024 * 1024; // 1 GB default } + if (i > 0) + { + if (getrlimit(RLIMIT_CORE, &rlim) < 0) + { + NSLog(@"Unable to get core file size limit: %d", errno); + } + else + { + if (rlim.rlim_max < i) + { + NSLog(@"Hard limit for core file size (%"PRIuPTR + @") less than requested (%"PRIdPTR, + (NSUInteger)rlim.rlim_max, i); + } + else + { + rlim.rlim_cur = i; + if (setrlimit(RLIMIT_CORE, &rlim) < 0) + { + NSLog(@"Unable to set core file size limit to %"PRIdPTR + @", errno: %d", i, errno); + } + } + } + } if (nil == noNetConfig) {