Re: File descriptors not freed up without a -closeFile call
Re: File descriptors not freed up without a -closeFile call
- Subject: Re: File descriptors not freed up without a -closeFile call
- From: Alastair Houghton <email@hidden>
- Date: Wed, 23 Jun 2010 14:35:11 +0100
On 23 Jun 2010, at 11:14, Ben Haller wrote:
> 3. I added [[pipe fileHandleForWriting] closeFile] and [[pipe fileHandleForReading] closeFile] calls to close the files associated with the pipes when my tasks completed. This change fixed the problem; I no longer run out of file descriptors.
Are you making the classic NSTask mistake of doing [pipe fileHandleForReading] or [pipe fileHandleForWriting] and then using that with -setStandardOutput: or -setStandardInput:?
NSTask is odd in this respect, in that you're supposed to just pass the *NSPipe*, not a file handle derived from it. If you do the latter, IIRC (from the last time I did this, which was ages ago) it may indeed leak file descriptors.
You only need an NSFileHandle where your process is going to actually read or write; they aren't used for passing pipe handles to subprocesses.
Kind regards,
Alastair.
--
http://alastairs-place.net
_______________________________________________
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