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: Thomas Deniau <email@hidden>
- Date: Thu, 03 Jan 2002 00:51:47 +0100
Le 2/01/02 15:40, [NAME] disait :
>
The problem is that notifications of available data on the output pipe
>
are fired only *after* "command" has exited! That is, the behaviour of
>
this code is as follows: "command" is run but no output is shown;
>
however, if the user presses a key, this is correctly sent to the input
>
pipe, so "command" (which was hanging on getchar()) goes on, writes
>
some other text and exits. At this point only notifications of available
>
data are sent, so the program displays all the output of "command",
>
before and after getchar()! I do not understand why. Can someone give me
>
some hint? Am I doing something wrong? If this is a bug, does a
>
workaround exist?
If had the same problem.
If you control command's code, just add fflush(stdout); where you use
printf.
This solved the problem for me.
(In fact I eventually used distributed notifications & distributed objects
to have a more flexible way of handling output)
--
Thomas Deniau