mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 00:41:02 +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
da27390636
commit
20519a6f6b
2 changed files with 74 additions and 32 deletions
|
@ -1,10 +1,12 @@
|
|||
2005-06-04 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
GSFileHandle.m:
|
||||
NSFileManager.m:
|
||||
* GSFileHandle.m:
|
||||
* NSFileManager.m:
|
||||
Define _FILE_OFFSET_BITS to be 64 so that, on unix-like systems which
|
||||
support large file handling (>2GB) the large file handling routines
|
||||
are used.
|
||||
* NSTask.m: Try to deal with pipes properly when launching under
|
||||
windows.
|
||||
|
||||
2005-05-21 Adam Fedor <fedor@gnu.org>
|
||||
|
||||
|
|
100
Source/NSTask.m
100
Source/NSTask.m
|
@ -1064,17 +1064,19 @@ quotedFromString(NSString *aString)
|
|||
|
||||
- (void) launch
|
||||
{
|
||||
DWORD tid;
|
||||
STARTUPINFOW start_info;
|
||||
NSString *lpath;
|
||||
NSString *arg;
|
||||
NSEnumerator *arg_enum;
|
||||
NSMutableString *args;
|
||||
wchar_t *w_args;
|
||||
int result;
|
||||
const wchar_t *wexecutable;
|
||||
LPVOID envp = 0;
|
||||
NSDictionary *env;
|
||||
DWORD tid;
|
||||
STARTUPINFOW start_info;
|
||||
NSString *lpath;
|
||||
NSString *arg;
|
||||
NSEnumerator *arg_enum;
|
||||
NSMutableString *args;
|
||||
wchar_t *w_args;
|
||||
int result;
|
||||
const wchar_t *wexecutable;
|
||||
LPVOID envp = 0;
|
||||
NSDictionary *env;
|
||||
NSMutableArray *toClose;
|
||||
NSFileHandle *hdl;
|
||||
|
||||
if (_hasLaunched)
|
||||
{
|
||||
|
@ -1143,9 +1145,37 @@ quotedFromString(NSString *aString)
|
|||
memset (&start_info, 0, sizeof(start_info));
|
||||
start_info.cb = sizeof(start_info);
|
||||
start_info.dwFlags |= STARTF_USESTDHANDLES;
|
||||
start_info.hStdInput = [[self standardInput] nativeHandle];
|
||||
start_info.hStdOutput = [[self standardOutput] nativeHandle];
|
||||
start_info.hStdError = [[self standardError] nativeHandle];
|
||||
|
||||
toClose = [NSMutableArray arrayWithCapacity: 3];
|
||||
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,
|
||||
w_args,
|
||||
|
@ -1175,6 +1205,16 @@ quotedFromString(NSString *aString)
|
|||
* Create thread to watch for termination of process.
|
||||
*/
|
||||
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
|
||||
|
@ -1250,22 +1290,22 @@ GSCheckTasks()
|
|||
- (void) launch
|
||||
{
|
||||
NSMutableArray *toClose;
|
||||
NSString *lpath;
|
||||
int pid;
|
||||
const char *executable;
|
||||
const char *path;
|
||||
int idesc;
|
||||
int odesc;
|
||||
int edesc;
|
||||
NSDictionary *e = [self environment];
|
||||
NSArray *k = [e allKeys];
|
||||
NSArray *a = [self arguments];
|
||||
int ec = [e count];
|
||||
int ac = [a count];
|
||||
const char *args[ac+2];
|
||||
const char *envl[ec+1];
|
||||
id hdl;
|
||||
int i;
|
||||
NSString *lpath;
|
||||
int pid;
|
||||
const char *executable;
|
||||
const char *path;
|
||||
int idesc;
|
||||
int odesc;
|
||||
int edesc;
|
||||
NSDictionary *e = [self environment];
|
||||
NSArray *k = [e allKeys];
|
||||
NSArray *a = [self arguments];
|
||||
int ec = [e count];
|
||||
int ac = [a count];
|
||||
const char *args[ac+2];
|
||||
const char *envl[ec+1];
|
||||
id hdl;
|
||||
int i;
|
||||
|
||||
if (_hasLaunched)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue