Skip to content

Commit

Permalink
output: Ensure we flush before closing a file
Browse files Browse the repository at this point in the history
Flush the file output before closing if the --flush flag is set.

Signed-off-by: Naushir Patuck <[email protected]>
  • Loading branch information
naushir committed Jun 22, 2023
1 parent 1a277d4 commit a1b2fdd
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions output/file_output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,12 @@ void FileOutput::openFile(int64_t timestamp_us)

void FileOutput::closeFile()
{
if (fp_ && fp_ != stdout)
fclose(fp_);
fp_ = nullptr;
if (fp_)
{
if (options_->flush)
fflush(fp_);
if (fp_ != stdout)
fclose(fp_);
fp_ = nullptr;
}
}

0 comments on commit a1b2fdd

Please sign in to comment.