diff --git a/ChangeLog b/ChangeLog index 23dc4e4..d0a8fae 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2015-03-26 Richard Frith-Macdonald + + * Control.plist: + * EcCommand.m: + * EcProcess.h: + * EcProcess.m: + New options for dealing with I/O. In EcProcess we can set + EcKeepStandardError to keep the stderr stream separate from the + debug logging file. + When a process is launched from the Command server, we can define + KeepStandardInput, KeepStandardOutput, and KeepStandardError flags + in the task info to stop the standard streams from being closed. + 2015-03-19 Richard Frith-Macdonald * EcProcess.m: diff --git a/Control.plist b/Control.plist index 1e2c18b..5bbe635 100644 --- a/Control.plist +++ b/Control.plist @@ -41,6 +41,9 @@ Home = "~xxx/Test"; // Directory to run in Args = ("-Debug", "YES"); // Args to launch with Auto = NO; // Auto-launch? + KeepStandardInput = YES; // Don't close stdin + KeepStandardOutput = YES; // Don't close stdout + KeepStandardError = YES; // Don't close stderr }; Bar = { Prog = "Bar"; // RName of binary diff --git a/EcCommand.m b/EcCommand.m index c0e2db7..b09edc1 100644 --- a/EcCommand.m +++ b/EcCommand.m @@ -1965,9 +1965,26 @@ static NSString* cmdWord(NSArray* a, unsigned int pos) } if (prog != nil) { - [task setStandardInput: hdl]; - [task setStandardOutput: hdl]; - [task setStandardError: hdl]; + NSString *s; + + s = [taskInfo objectForKey: @"KeepStandardInput"]; + if (NO == [s respondsToSelector: @selector(boolValue)] + || NO == [s boolValue]) + { + [task setStandardInput: hdl]; + } + s = [taskInfo objectForKey: @"KeepStandardOutput"]; + if (NO == [s respondsToSelector: @selector(boolValue)] + || NO == [s boolValue]) + { + [task setStandardOutput: hdl]; + } + s = [taskInfo objectForKey: @"KeepStandardError"]; + if (NO == [s respondsToSelector: @selector(boolValue)] + || NO == [s boolValue]) + { + [task setStandardError: hdl]; + } if (home != nil && [home length] > 0) { [task setCurrentDirectoryPath: home]; diff --git a/EcProcess.h b/EcProcess.h index 133f12f..fcc6065 100644 --- a/EcProcess.h +++ b/EcProcess.h @@ -76,6 +76,14 @@ number of open file descriptors has been reached, rather than waiting for the operating system imposed limit. + EcKeepStandardError + + This boolean value determines whether the standard error output + should be kept as it is on process startup, or should be merged + with the local debug log to file.
+ The default (EcKeepStandardError set to NO) is to merge the + standard error logging with the debug logging. +
EcMemory This boolean value determines whether statistics on creation diff --git a/EcProcess.m b/EcProcess.m index 7c5bae6..365e44f 100644 --- a/EcProcess.m +++ b/EcProcess.m @@ -123,6 +123,7 @@ static BOOL cmdFlagDaemon = NO; static BOOL cmdFlagTesting = NO; static BOOL cmdIsQuitting = NO; static BOOL cmdIsRunning = NO; +static BOOL cmdKeepStderr = NO; static NSInteger cmdQuitStatus = 0; static NSString *cmdInst = nil; static NSString *cmdName = nil; @@ -1514,7 +1515,7 @@ static NSString *noFiles = @"No log files to archive"; * As a special case, if this is the default debug file * we must set it up to write to stderr. */ - if ([name isEqual: cmdDebugName] == YES) + if (NO == cmdKeepStderr && [name isEqual: cmdDebugName] == YES) { int desc; @@ -3741,6 +3742,11 @@ NSLog(@"Ignored attempt to set timer interval to %g ... using 10.0", interval); } } + /* See if we should keep stderr separate, or merge it with + * our debug output (the default). + */ + cmdKeepStderr = [cmdDefs boolForKey: @"KeepStandardError"]; + if (nil == noNetConfig) { noNetConfig = [[NSMutableArray alloc] initWithCapacity: 4];