mirror of
https://github.com/gnustep/libs-base.git
synced 2025-06-04 02:20:48 +00:00
Attempt to hanlde pipes properly under windows
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@21274 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
655edeb705
commit
6e3bf6d8a1
2 changed files with 74 additions and 32 deletions
|
@ -1,10 +1,12 @@
|
||||||
2005-06-04 Richard Frith-Macdonald <rfm@gnu.org>
|
2005-06-04 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
GSFileHandle.m:
|
* GSFileHandle.m:
|
||||||
NSFileManager.m:
|
* NSFileManager.m:
|
||||||
Define _FILE_OFFSET_BITS to be 64 so that, on unix-like systems which
|
Define _FILE_OFFSET_BITS to be 64 so that, on unix-like systems which
|
||||||
support large file handling (>2GB) the large file handling routines
|
support large file handling (>2GB) the large file handling routines
|
||||||
are used.
|
are used.
|
||||||
|
* NSTask.m: Try to deal with pipes properly when launching under
|
||||||
|
windows.
|
||||||
|
|
||||||
2005-05-21 Adam Fedor <fedor@gnu.org>
|
2005-05-21 Adam Fedor <fedor@gnu.org>
|
||||||
|
|
||||||
|
|
|
@ -1075,6 +1075,8 @@ quotedFromString(NSString *aString)
|
||||||
const wchar_t *wexecutable;
|
const wchar_t *wexecutable;
|
||||||
LPVOID envp = 0;
|
LPVOID envp = 0;
|
||||||
NSDictionary *env;
|
NSDictionary *env;
|
||||||
|
NSMutableArray *toClose;
|
||||||
|
NSFileHandle *hdl;
|
||||||
|
|
||||||
if (_hasLaunched)
|
if (_hasLaunched)
|
||||||
{
|
{
|
||||||
|
@ -1143,9 +1145,37 @@ quotedFromString(NSString *aString)
|
||||||
memset (&start_info, 0, sizeof(start_info));
|
memset (&start_info, 0, sizeof(start_info));
|
||||||
start_info.cb = sizeof(start_info);
|
start_info.cb = sizeof(start_info);
|
||||||
start_info.dwFlags |= STARTF_USESTDHANDLES;
|
start_info.dwFlags |= STARTF_USESTDHANDLES;
|
||||||
start_info.hStdInput = [[self standardInput] nativeHandle];
|
|
||||||
start_info.hStdOutput = [[self standardOutput] nativeHandle];
|
toClose = [NSMutableArray arrayWithCapacity: 3];
|
||||||
start_info.hStdError = [[self standardError] nativeHandle];
|
hdl = [self standardInput];
|
||||||
|
if ([hdl isKindOfClass: [NSPipe class]])
|
||||||
|
{
|
||||||
|
hdl = [hdl fileHandleForReading];
|
||||||
|
[toClose addObject: hdl];
|
||||||
|
}
|
||||||
|
start_info.hStdInput = [hdl nativeHandle];
|
||||||
|
|
||||||
|
hdl = [self standardOutput];
|
||||||
|
if ([hdl isKindOfClass: [NSPipe class]])
|
||||||
|
{
|
||||||
|
hdl = [hdl fileHandleForWriting];
|
||||||
|
[toClose addObject: hdl];
|
||||||
|
}
|
||||||
|
start_info.hStdOutput = [hdl nativeHandle];
|
||||||
|
|
||||||
|
hdl = [self standardError];
|
||||||
|
if ([hdl isKindOfClass: [NSPipe class]])
|
||||||
|
{
|
||||||
|
hdl = [hdl fileHandleForWriting];
|
||||||
|
/*
|
||||||
|
* If we have the same pipe twice we don't want to close it twice
|
||||||
|
*/
|
||||||
|
if ([toClose indexOfObjectIdenticalTo: hdl] == NSNotFound)
|
||||||
|
{
|
||||||
|
[toClose addObject: hdl];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
start_info.hStdError = [hdl nativeHandle];
|
||||||
|
|
||||||
result = CreateProcessW(wexecutable,
|
result = CreateProcessW(wexecutable,
|
||||||
w_args,
|
w_args,
|
||||||
|
@ -1175,6 +1205,16 @@ quotedFromString(NSString *aString)
|
||||||
* Create thread to watch for termination of process.
|
* Create thread to watch for termination of process.
|
||||||
*/
|
*/
|
||||||
wThread = CreateThread(NULL, 0, _threadFunction, (LPVOID)self, 0, &tid);
|
wThread = CreateThread(NULL, 0, _threadFunction, (LPVOID)self, 0, &tid);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Close the ends of any pipes used by the child.
|
||||||
|
*/
|
||||||
|
while ([toClose count] > 0)
|
||||||
|
{
|
||||||
|
hdl = [toClose objectAtIndex: 0];
|
||||||
|
[hdl closeFile];
|
||||||
|
[toClose removeObjectAtIndex: 0];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) _collectChild
|
- (void) _collectChild
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue