• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Can't obtain any more NSPipe instances
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Can't obtain any more NSPipe instances


  • Subject: Re: Can't obtain any more NSPipe instances
  • From: Alexander Reichstadt <email@hidden>
  • Date: Mon, 29 May 2006 19:31:01 +0200

Thanks to all who replied, this was very helpful, I got my app fixed and it works fine now.

Alex


On 29.05.2006, at 04:10, Glenn Zelniker wrote:


On May 28, 2006, at 9:55 PM, Alexander Reichstadt wrote:

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?

I got bitten by this bug once. If I remember correctly, you're running out of file descriptors. Try sending the readHandle a - closeFile message; this should take care of the problem.


Glenn Z

_______________________________________________ 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
References: 
 >Can't obtain any more NSPipe instances (From: Alexander Reichstadt <email@hidden>)
 >Re: Can't obtain any more NSPipe instances (From: Glenn Zelniker <email@hidden>)

  • Prev by Date: RE: Installer Check to see if it's an Intel Mac
  • Next by Date: NSDocument - preventing incomplete document from being saved
  • Previous by thread: Re: Can't obtain any more NSPipe instances
  • Next by thread: Re: Can't obtain any more NSPipe instances
  • Index(es):
    • Date
    • Thread