I am writing to a log file in an app. Normally I write to it and then come back 2 seconds later and call the flush method on the stream so that I dont call it with every write. Some things generate many log writes at once and I dont need to flush it every write. I have users who want to do a tail -f on the file but the file isnt updated with the calls to flush at all. Its anywhere from 15 seconds to several minutes later that things show up in the actual file. The call to flush also seems to use almost no CPU time at all. If I close the file and re-open it then the data is written to disk.
What exactly is flush supposed to do? Is this just a matter of how removed we are from the file system in the OS? Or do I not understand what its supposed to do? It definitely does not cause the write buffers to go to disk.