![]() |
|
|
|
#1
|
||||
|
||||
|
There is an ANSI C _flushall() command that causes all open buffers to be flushed to file. There is also a stream.flush() function if you are using C++ stream i/o. They may help, but I am not quite sure what you mean by flushing an input buffer, but if you don't have the source code to prog1 I don't see how you can affect it's behaviour. Unless.. if you can redirect stdout to a pipe then i/o can be made non-buffered, but I am still unsure if it can work.
Git Last edited by Git; 07-10-2011 at 00:54. |
| The Following User Gave Reputation+1 to Git For This Useful Post: | ||
chessgod101 (07-10-2011) | ||
|
#2
|
|||
|
|||
|
"prog1.exe" writes to the console. The default behavior ist unbuffered. The output will be written to the console every 60 seconds.
As soon as the output is redirected (to file ">>" or to pipeline "|"), the OS (both Windows and Linux) switch to buffered output. This means the output will be only written when the output buffer is full, which takes about 40 minutes each time. Somebody could "flush" the output buffer, which would write the contents of the buffer at once, even if it isn't full yet. Or somebody could enable unbuffered output again. But both changes would need to change "prog1.exe", something which is not possible in this situation. The other end of the pipeline belongs to "tee.exe" (full source available). It reads all data from the standard input. The problem is that "tee.exe" only gets something to read when "prog1.exe" sends something, which will only happen when its output buffer is full. Flushing the input buffer would mean something like "Dear OS, please send me all data from prog1.exe, even if the buffer is not full yet". Unfortunately this kind of command is not supported for some reason. I also tried to set "stdin" to unbuffered without success. Using a very small buffer for "stdin" didn't help either, data was only available for read when the output buffer of "prog1.exe" was full, not earlier. |
![]() |
|
|
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 |