mirror of
https://github.com/gnustep/libs-ec.git
synced 2025-02-21 02:41:11 +00:00
allow unlimited core dump size
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/ec/trunk@36589 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
07bf4d6b99
commit
04f4fc996f
2 changed files with 45 additions and 19 deletions
|
@ -54,8 +54,9 @@
|
|||
<desc>
|
||||
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.
|
||||
If this is not set, the default size of 1GB is used.<br />
|
||||
If this is negative, the size is unlimited.<br />
|
||||
If this is zero then no core dumping is performed.
|
||||
</desc>
|
||||
<term>EcDebug-</term>
|
||||
<desc>
|
||||
|
|
59
EcProcess.m
59
EcProcess.m
|
@ -448,7 +448,7 @@ static NSMutableArray *noNetConfig = nil;
|
|||
|
||||
static NSMutableDictionary *servers = nil;
|
||||
|
||||
static int coreSize = 0;
|
||||
static int coreSize = -2; // Not yet set
|
||||
|
||||
static NSString *hostName = nil;
|
||||
static NSString *
|
||||
|
@ -1097,10 +1097,18 @@ static NSString *noFiles = @"No log files to archive";
|
|||
}
|
||||
}
|
||||
|
||||
i = (int)[cmdDefs integerForKey: @"CoreSize"];
|
||||
if (i < 0)
|
||||
str = [cmdDefs stringForKey: @"CoreSize"];
|
||||
if (nil == str)
|
||||
{
|
||||
i = 1024; // 1 GB default
|
||||
i = 1024; // 1 GB default
|
||||
}
|
||||
else
|
||||
{
|
||||
i = [str intValue];
|
||||
if (i < 0)
|
||||
{
|
||||
i = -1; // unlimited
|
||||
}
|
||||
}
|
||||
if (i != coreSize)
|
||||
{
|
||||
|
@ -1108,29 +1116,46 @@ static NSString *noFiles = @"No log files to archive";
|
|||
rlim_t want;
|
||||
|
||||
coreSize = i;
|
||||
want = i * 1024 * 1024;
|
||||
if (i > 0)
|
||||
if (coreSize < 0)
|
||||
{
|
||||
if (getrlimit(RLIMIT_CORE, &rlim) < 0)
|
||||
want = RLIM_INFINITY;
|
||||
}
|
||||
else
|
||||
{
|
||||
want = i * 1024 * 1024;
|
||||
}
|
||||
if (getrlimit(RLIMIT_CORE, &rlim) < 0)
|
||||
{
|
||||
NSLog(@"Unable to get core file size limit: %d", errno);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (RLIM_INFINITY != rlim.rlim_max && rlim.rlim_max < want)
|
||||
{
|
||||
NSLog(@"Unable to get core file size limit: %d", errno);
|
||||
NSLog(@"Hard limit for core file size (%dMB)"
|
||||
@" less than requested (%dMB)",
|
||||
(int)(rlim.rlim_max/(1024*1024)), coreSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (rlim.rlim_max < want)
|
||||
rlim.rlim_cur = want;
|
||||
if (setrlimit(RLIMIT_CORE, &rlim) < 0)
|
||||
{
|
||||
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)
|
||||
if (coreSize > 0)
|
||||
{
|
||||
NSLog(@"Unable to set core file size limit to %uMB"
|
||||
@", errno: %d", coreSize, errno);
|
||||
}
|
||||
else if (coreSize < 0)
|
||||
{
|
||||
NSLog(@"Unable to set core file size unlimited"
|
||||
@", errno: %d", errno);
|
||||
}
|
||||
else
|
||||
{
|
||||
NSLog(@"Unable to set core dumps disabled"
|
||||
@", errno: %d", errno);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue