#1
|
|||
|
|||
Flushing input stream
I've a little programming related problem and I don't know how to solve it.
A console program (lets call it "prog1.exe") has the following pseudo-code: Code:
while not (Ctrl_Break) { x = fetch_stats(); // Read some info writeconsole(x); // Output the info to the console wait(60); // Wait 60 seconds and repeat the whole process } Code:
while not (EndOfFile(StdIn)) { c = read(StdIn); // Read one char from StdIn write(StdOut, c); // Write one char to StdOut write(FILE, c); // Write the same char to a file } The problem is the output buffer. For performance reasons, the OS doesn't write the output of "prog1.exe" to "tee.exe" char-by-char, but waits until the output buffer is full and then writes the whole buffer to "tee.exe". Since "prog1.exe" does only output a few bytes every minute, it takes about 40 minutes before the output buffer is full and transfered to "tee.exe". Running "prog1.exe >> output.txt" has a similar result: There is no output to the console any more und the file is also only updated when the output buffer is full. I don't have access to "prog1.exe" or it's source code, so I can't flush the output buffer. Flushing the input buffer is not possible for some reason. The only workarounds I found for the problem describe how to flush the keyboard buffer. Does anybody have an idea how to solve this problem? My goal is simple: 1. See the console output in real time 2. Write the console output to a file |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[ARMADILLO] 1 serial & 1 key - need input | Maltese | General Discussion | 2 | 02-18-2005 00:58 |