Problem with redirecting stdout

2010-11-09 Thread Edmond Ho
Hello all, I am having some trouble with capturing and redirecting stdout in my Cocoa application. A little bit of background: My app has an embedded scripting language interpreter, and I would like to redirect stdout in order to display the results of executed scripts in an NSTextView. I've

Re: Problem with redirecting stdout

2010-11-09 Thread Ken Thomases
On Nov 9, 2010, at 5:48 PM, Edmond Ho wrote: To summarize, I use dup2() to bind stdout to my own NSPipe, and then add an NSNotification observer to listen for an NSFileHandleReadCompletionNotification on the NSPipe; the notification callback then reads the NSPipe. NSFileHandle

Re: Problem with redirecting stdout

2010-11-09 Thread Dave Keck
I think the problem is that the pipe buffer is not being flushed/read when it's full; when the pipe is full, the script interpreter then is blocked because it's waiting for the pipe to empty so that it can write. I don't fully understand the structure of your program, but indeed it sounds like