thanks again,
everithing works, but i'm writing the output to a textwindow
(Tk: Scrolled text) and it refreshes it only after the redirected program ends. It *, is it possible to solve this
problem?
Edited by Chady -- converted pre to p tags.
| [reply] |
That probably depends on the external program you are calling.
Libc normally sets up a stream buffered, more precisely line buffered if it's connected to a terminal, full buffered otherwise. This means that unless the program you call will do explicitly otherwise, you'll get the output only after each newline if it's connected to a terminal, but the newline does not flush the buffer if it's connected to a pipe as in your case, so you'll get the output chunk by chunk. Some programs (like cat) are intelligent enought to smartly override this, but some programs just leave it as is (the most annoying one being gnu tr).
If the program you call is a perl script you have written, you can edit it to flush the output whenever you need it to appear (with use IO "Hanlder"; flush STDOUT; on newer perls). If it's a C program you wrote, you can flush the output with fflush(stdout), or force line buffering with setlinebuf(stdout); (I'm not sure in this one).
If it's a program you cannot change, you probably can't do many things, except maybe to call if through a virtual terminal, which I don't know how to do from perl, and can have other effects.
| [reply] [d/l] [select] |
you dont understand me. everything works, I have the output
of the program (the program is in perl, my is in perl/tk,
it is a GUI). I can write to the textwindow, but my program
does nothing (like frozen) till the other program ends. and
this is a problem, while the other program runs,my should
too ! I tried to run the program in the background (&), but
nothing.
| [reply] |