• 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: running out of NSPipes
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: running out of NSPipes


  • Subject: Re: running out of NSPipes
  • From: Jens Alfke <email@hidden>
  • Date: Fri, 18 Apr 2008 21:39:19 -0700


On 18 Apr '08, at 7:21 PM, justin webster wrote:

the trick, I think, was fflush() and pclose(). perhaps NSPipe is missing some tidy-up code.

I don't think so; more likely the NSPipe instances weren't being released at the end of each loop iteration.


FILE *rtn = popen([@"ls" cString], [@"r" cString]);

popen can be dangerous, since you're giving it a bash command line. If you're not very careful about quoting metacharacters like spaces and asterisks, the arguments can get misinterpreted, causing various problems. (One particular version of Apple's iTunes installer had a bug like this, which caused several people's entire hard disks to be erased because they had spaces in their names.)


execv is much safer since it takes an argument list, and runs the tool directly instead of invoking a shell, so there is no quoting going on. You have to call fork first, though, to actually spawn a new process.

Or you could keep using NSTask and just wrap your loop in an autorelease pool, as people suggested.

—Jens

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

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

References: 
 >Re: running out of NSPipes (From: Scott Ribe <email@hidden>)
 >Re: running out of NSPipes (From: justin webster <email@hidden>)

  • Prev by Date: Re: Simulating menu bar blink in Cocoa
  • Next by Date: Re: Hand style movement inside a NSScrollView
  • Previous by thread: Re: running out of NSPipes
  • Next by thread: Re: running out of NSPipes
  • Index(es):
    • Date
    • Thread