Can't obtain any more NSPipe instances
Can't obtain any more NSPipe instances
- Subject: Can't obtain any more NSPipe instances
- From: Alexander Reichstadt <email@hidden>
- Date: Mon, 29 May 2006 03:55:39 +0200
Hi,
There is some odd behaviour with NSPipe I can't figure out, or maybe
it's with my code. The following demonstrates the problem; when
running the following code it always fails at iteration 246:
- (IBAction)test:(id)sender
{
int i;
for (i=0;i<1000;i++){
NSTask *task = [[NSTask alloc] init];
NSPipe *pipe = [NSPipe pipe];
if (!pipe){
NSLog(@"we got to iteration %i before failing to obtain an NSPipe
instance",i);
break;
}
NSFileHandle *readHandle = [pipe fileHandleForReading];
[task setStandardOutput:pipe];
[task setLaunchPath:@"/bin/ls"];
[task setArguments:[NSArray arrayWithObject:@"/"]];
[task waitUntilExit];
[task launch];
[task release];
}
}
Without the break statement it is going to crash with an exception
where nil is being inserted into an NSDictionary, catching this
exception doesn't work. In my app I am running command line tools in
the background, and after a couple of hours I get the same problem
causing for my app to need to be relaunched. In the above example I
only need to trigger the action again, and it will work, no relaunch
required.
Why does it fail at 246, is there anything I can do differently to
remove the limit of NSPipe instances I can obtain?
Thanks
Alex
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden