Re: NSTask, NSPipe's and interactive UNIX command
Re: NSTask, NSPipe's and interactive UNIX command
- Subject: Re: NSTask, NSPipe's and interactive UNIX command
- From: Chris Kane <email@hidden>
- Date: Thu, 3 Jan 2002 12:59:29 -0800
On Thursday, January 3, 2002, at 05:57 AM, Nicola Vitacolonna wrote:
Buffering of stdout is line-buffered by default if the output file
descriptor is a tty (or pty); otherwise, block buffered. stderr is by
default unbuffered. The setvbuf() function is used to change the
buffering mode. These are all standard BSD UNIX (and maybe general
UNIX) things I've described here.
NSTask does not do any setting up of ttys/ptys for you. It wouldn't
help in this case anyway since the printfs aren't printing out \n.
Ok, you can assume that my output actually prints \n in each printf().
My question is: is there a way to set up a pty in Cocoa using NSPipe
and NSTask? Or should I use standard C libraries to do the job (I've
been suggested to make a thread, use a standard read() and set up
communication with NSConnection).
If flushing from the command-line utility is the problem, no amount of
reading threads in the parent is going to help you.
Cocoa does not have any facilities to do this. You have to use BSD
calls. Code to do this was posted to this or the OmniGroup macosx-dev
mailing list (archives of that at www.omnigroup.com) within the past two
months.
Chris Kane
Cocoa Frameworks, Apple