Change core size setting to use MB and fix to update dynamically

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/ec/trunk@36588 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2013-04-30 06:57:37 +00:00
parent 23100989c4
commit 07bf4d6b99
2 changed files with 44 additions and 34 deletions

View file

@ -52,8 +52,8 @@
<deflist>
<term>EcCoreSize</term>
<desc>
Specifies the maximum size (in bytes) for any core-dump of the
process.
Specifies the maximum size (in MB) for any core-dump of the
process.<br />
If this is negative, the default size of 1GB is used.<br />
If this is zero (or no value is set) then no limit is set.
</desc>

View file

@ -448,6 +448,8 @@ static NSMutableArray *noNetConfig = nil;
static NSMutableDictionary *servers = nil;
static int coreSize = 0;
static NSString *hostName = nil;
static NSString *
ecHostName()
@ -1050,6 +1052,7 @@ static NSString *noFiles = @"No log files to archive";
NSDictionary *dict;
NSString *mode;
NSString *str;
int i;
enumerator = [cmdDebugKnown keyEnumerator];
while (nil != (mode = [enumerator nextObject]))
@ -1094,6 +1097,45 @@ static NSString *noFiles = @"No log files to archive";
}
}
i = (int)[cmdDefs integerForKey: @"CoreSize"];
if (i < 0)
{
i = 1024; // 1 GB default
}
if (i != coreSize)
{
struct rlimit rlim;
rlim_t want;
coreSize = i;
want = i * 1024 * 1024;
if (i > 0)
{
if (getrlimit(RLIMIT_CORE, &rlim) < 0)
{
NSLog(@"Unable to get core file size limit: %d", errno);
}
else
{
if (rlim.rlim_max < want)
{
NSLog(@"Hard limit for core file size (%dMB)"
@" less than requested (%dMB)",
(int)(rlim.rlim_max/(1024*1024)), coreSize);
}
else
{
rlim.rlim_cur = want;
if (setrlimit(RLIMIT_CORE, &rlim) < 0)
{
NSLog(@"Unable to set core file size limit to %uMB"
@", errno: %d", coreSize, errno);
}
}
}
}
}
if (servers != nil)
{
NSEnumerator *e;
@ -3040,7 +3082,6 @@ NSLog(@"Ignored attempt to set timer interval to %g ... using 10.0", interval);
}
else
{
struct rlimit rlim;
NSProcessInfo *pinfo;
NSFileManager *mgr;
NSEnumerator *enumerator;
@ -3178,37 +3219,6 @@ NSLog(@"Ignored attempt to set timer interval to %g ... using 10.0", interval);
}
}
i = [cmdDefs integerForKey: @"CoreSize"];
if (i < 0)
{
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)
{
noNetConfig = [[NSMutableArray alloc] initWithCapacity: 4];