• 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: File descriptors not freed up without a -closeFile call
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: File descriptors not freed up without a -closeFile call
      • From: Ben Haller <email@hidden>
References: 
 >File descriptors not freed up without a -closeFile call (From: Ben Haller <email@hidden>)

  • Prev by Date: Re: Using Field Editor correctly in custom NSCell
  • Next by Date: Re: Custom views in navigationbar (iOS 3.2)
  • Previous by thread: Re: File descriptors not freed up without a -closeFile call
  • Next by thread: Re: File descriptors not freed up without a -closeFile call
  • Index(es):
    • Date
    • Thread