Add some fine control over standard IO stream handling

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/ec/trunk@38434 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2015-03-26 11:33:02 +00:00
parent ccfe71f75d
commit 1efeaea3e4
5 changed files with 51 additions and 4 deletions

View file

@ -1,3 +1,16 @@
2015-03-26 Richard Frith-Macdonald <rfm@gnu.org>
* 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 <rfm@gnu.org>
* EcProcess.m:

View file

@ -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

View file

@ -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];

View file

@ -76,6 +76,14 @@
number of open file descriptors has been reached, rather
than waiting for the operating system imposed limit.
</desc>
<term>EcKeepStandardError</term>
<desc>
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.<br />
The default (EcKeepStandardError set to NO) is to merge the
standard error logging with the debug logging.
</desc>
<term>EcMemory</term>
<desc>
This boolean value determines whether statistics on creation

View file

@ -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];