Re: running out of NSPipes
Re: running out of NSPipes
- Subject: Re: running out of NSPipes
- From: Ken Thomases <email@hidden>
- Date: Fri, 18 Apr 2008 14:15:07 -0500
On Apr 18, 2008, at 4:23 AM, justin webster wrote:
so I see at least one other thread on this topic but no real solution.
the situation is:
using NSTask to run a shell command and using the return.
all the NSTask stuff is in a separate function which gets called
repeatedly from a loop.
works great until I run out out NSPipes - about 248 iterations
before [NSPipe pipe] returns nil.
I have the function wrapped in an autorelease pool and have tried
explicitly allocating and releasing the NSPipe.
the [myTask waitUntilExit] solution mentioned in another thread made
no difference.
does anyone understand what causes this limitaion?
is there another way to get a return from the shell?
system() does what I need, as often as you like, except I can't get
the return value.
What Scott Ribe said is almost certainly the proper way to address
this issue.
However, for completeness I will mention that setrlimit() can be used
to bump the limit on open file descriptors up to OPEN_MAX (10240).
Also, the popen() call can be used as an alternative to NSTask to run
a command and write data to its input and read data from its output.
Neither will help you if you aren't properly managing resources,
though -- you'll still eventually hit the resource limits. So, better
to fix the resource management bugs than resort to these workarounds.
Cheers,
Ken
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden