Re: NSTask Memory Problems
Re: NSTask Memory Problems
- Subject: Re: NSTask Memory Problems
- From: Daryn <email@hidden>
- Date: Fri, 23 Jan 2004 01:08:17 -0600
I'll apologize in advance for not answering your actual question,
because I don't immediately notice a crashing bug in the code provided.
I do notice something else that may cause you trouble: invoking
waitUntilExit and then later collecting all output from the task.
Deadlock will result if & when the child process fills the pipe buffer
and it's not being read because the parent is waiting for the child to
exit, yet the child is waiting for the parent to read the pipe.
On Jan 22, 2004, at 7:50 PM, Owen Anderson wrote:
>
Hey,
>
>
I was trying to use this snippet I got off the this list a while back,
>
and I'm having troubles with it. The following snippet works
>
beautifully the first time, but crashes on the waitUntilExit the second
>
time round. Any suggestions?
>
>
Owen
>
>
-(NSArray*)findIt:(NSURL*)theURL
>
{
>
NSString* finder = [[[NSBundle mainBundle] pathForResource:@"finder"
>
ofType:@"py"] stringByStandardizingPath];
>
NSString* target = [theURL absoluteString];
>
>
NSTask* search = [[NSTask alloc] init];
>
[search setLaunchPath:@"/usr/bin/python"];
>
NSMutableArray* args = [[NSMutableArray alloc] init];
>
[args addObject:finder];
>
[args addObject:target];
>
[search setArguments:args];
>
[search setStandardOutput:[NSPipe pipe]];
>
[search setCurrentDirectoryPath:@"/"];
>
[search launch];
>
[search waitUntilExit];
>
>
NSData *data;
>
NSString* tmpString;
>
data = [[[search standardOutput] fileHandleForReading] availableData];
>
if ((data != nil) && [data length]) {
>
tmpString = [[[NSString alloc] initWithData:data
>
encoding:NSUTF8StringEncoding] autorelease];
>
}
>
>
[args release];
>
[search release];
>
>
return [tmpString componentsSeparatedByString:@"\n"];
>
}
>
_______________________________________________
>
cocoa-dev mailing list | email@hidden
>
Help/Unsubscribe/Archives:
>
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
>
Do not post admin requests to the list. They will be ignored.
[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.