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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to