2

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.)

3

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.