log/windows: Close stdout and stderr on destruction if redirected

No real reason to do this since these resources should be automatically
released on process exit anyway, but, better safe than sorry I guess.
This commit is contained in:
Ignacio R. Morelle 2015-11-23 00:24:57 -03:00
parent 900dc5b070
commit bc9fb0c111

View file

@ -208,6 +208,7 @@ class log_file_manager : private boost::noncopyable
{
public:
log_file_manager();
~log_file_manager();
/**
* Returns the path to the current log file.
@ -285,6 +286,18 @@ log_file_manager::log_file_manager()
LOG_LS << "Opened log file at " << new_path << '\n';
}
log_file_manager::~log_file_manager()
{
if(cur_path_.empty()) {
// No log file, nothing to do.
return;
}
DBG_LS << "Closing log file...\n";
fclose(stdout);
fclose(stderr);
}
std::string log_file_manager::log_file_path() const
{
return cur_path_;