I have a C++ ofstream that, for performance reasons, I don't flush from inside the code. However, occasionally I need to inspect the file contents. Is there a Linux command that will force the stream to flush to the file? (I.e., while the writing program is still running and holding the stream open.)
Is there a Linux command that will force the stream to flush to the file?
Not really, but the standard approach is to install a signal handler for, say,
SIGUSR1. The signal handler would set a flag, then your program would check the flag once in a while, and flush the relevant streams, and perhaps also print some relevant state information.