Skip navigation.
 
mlRe: running out of NSPipes
FROM : Jens Alfke
DATE : Sat Apr 19 06:39:19 2008

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

Related mailsAuthorDate
mlrunning out of NSPipes justin webster Apr 18, 11:23
mlRe: running out of NSPipes Scott Ribe Apr 18, 14:21
mlRe: running out of NSPipes Ken Thomases Apr 18, 21:15
mlRe: running out of NSPipes justin webster Apr 19, 04:21
mlRe: running out of NSPipes Jens Alfke Apr 19, 06:39
mlRe: running out of NSPipes justin webster Apr 19, 06:58
mlRe: running out of NSPipes Bob Smith Apr 19, 09:45
mlRe: running out of NSPipes Jens Alfke Apr 19, 17:20