Re: NSTask and avoiding buffered standard out
Re: NSTask and avoiding buffered standard out
- Subject: Re: NSTask and avoiding buffered standard out
- From: Ingvar Nedrebo <email@hidden>
- Date: Wed, 14 Aug 2002 18:43:01 +0100
On Monday, August 12, 2002, at 10:31 , Jim Correia wrote:
<snip>
I tried getting rid of the buffer on stdout, but that didn't seem to do
the trick.
#include <stdio.h>
int main (int argc, const char * argv[])
{
FILE *stream = popen("/Users/correia/Desktop/std-
test/build/std-test", "r");
char buffer[1024];
if (0 != setvbuf(stream, NULL, _IONBF, 0))
printf("setvbuf failed\n\n\n");
while (NULL != fgets(buffer, 1024, stream))
{
printf("%s", buffer);
}
pclose(stream);
return 0;
}
The setvbuf call needs to be in the client tool, your "std-test".
Is there a way to avoid this buffering without writing a pseudo tty
(which is ugly and not something I want to do if I can avoid it.)
If you control the tool you can call setvbuf in the tool. If you don't
have access to the source, then pseudo TTYs are your only choice. I have
some code at <
http://homepage.mac.com/inedrebo> that you can use if you
like.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.