improve instance id handling

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/ec/trunk@38817 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2015-07-21 09:30:24 +00:00
parent 7acbd5f539
commit 9d42bf3c19
3 changed files with 46 additions and 3 deletions

View file

@ -1,4 +1,12 @@
2015-07-21 Richard Frith-Macdonald <rfm@gnu.org>
* EcProcess.h:
* EcProcess.m:
Be more rigorous about checking instance id values. Ignore anything
other than a non-negative integer instance ID.
2015-07-15 Niels Grewe <niels.grewe@halbordnung.de>
* EcMemoryLogger.h
* EcProcess.m:
Add the ability to load a bundle to export memory logs to. Configured

View file

@ -215,7 +215,7 @@ extern NSString* cmdVersion(NSString *ver);
* rather than changing.
* </desc>
* <term>EcInstance</term>
* <desc>To set the program instance ID (an arbitrary string).<br />
* <desc>To set the program instance ID (a non-negative integer value).<br />
* If this is specified, the program name has a hyphen and the
* id appended to it by the '-initWithDefaults:' method.
* </desc>
@ -801,6 +801,12 @@ extern NSString* cmdVersion(NSString *ver);
*/
- (void) triggerCmdTimeout;
/** Returns the base name for this process (before any instance ID was
* added). If the process has no instance ID, this returns the same as
* the -cmdName method.
*/
- (NSString*) cmdBase;
/** Deprecated ... use -cmdDefaults instead.
*/
- (id) cmdConfig: (NSString*)key;
@ -818,6 +824,10 @@ extern NSString* cmdVersion(NSString *ver);
*/
- (NSUserDefaults*) cmdDefaults;
/** Returns the instance ID used for this process, or nil if there is none.
*/
- (NSString*) cmdInstance;
/** Utility method to perform partial (case insensitive) matching of
* an abbreviated command word (val) to a keyword (key)
*/
@ -827,7 +837,7 @@ extern NSString* cmdVersion(NSString *ver);
*/
- (NSString*) cmdMesg: (NSArray*)msg;
/** Retrurns the name by which this process is known to the Command server.
/** Returns the name by which this process is known to the Command server.
*/
- (NSString*) cmdName;

View file

@ -125,6 +125,7 @@ static BOOL cmdIsQuitting = NO;
static BOOL cmdIsRunning = NO;
static BOOL cmdKeepStderr = NO;
static NSInteger cmdQuitStatus = 0;
static NSString *cmdBase = nil;
static NSString *cmdInst = nil;
static NSString *cmdName = nil;
static NSString *cmdUser = nil;
@ -1170,6 +1171,11 @@ findMode(NSDictionary* d, NSString* s)
static NSString *noFiles = @"No log files to archive";
- (NSString*) cmdBase
{
return cmdBase;
}
- (id) cmdConfig: (NSString*)key
{
return [cmdDefs objectForKey: key];
@ -3880,6 +3886,13 @@ With two parameters ('maximum' and a number),\n\
ASSIGN(cmdName, [pinfo processName]);
}
/* This is the base name of the process (without instance)
*/
if (nil == cmdBase)
{
ASSIGN(cmdBase, cmdName);
}
/*
* Make sure our users home directory exists.
*/
@ -3977,7 +3990,19 @@ With two parameters ('maximum' and a number),\n\
}
}
ASSIGN(cmdInst, [cmdDefs stringForKey: @"Instance"]);
str = [[cmdDefs stringForKey: @"Instance"] stringByTrimmingSpaces];
if (nil != str)
{
if ([str length] > 0 && isdigit([str characterAtIndex: 0]))
{
str = [NSString stringWithFormat: @"%d", [str intValue]];
}
else
{
str = nil;
}
}
ASSIGN(cmdInst, str);
if (nil != cmdInst)
{
str = [[NSString alloc] initWithFormat: @"%@-%@", cmdName, cmdInst];