diff options
Diffstat (limited to 'util/log.c')
-rw-r--r-- | util/log.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/util/log.c b/util/log.c index 439541a7ce4a..c14b45834add 100644 --- a/util/log.c +++ b/util/log.c @@ -103,8 +103,12 @@ log_init(const char* filename, int use_syslog, const char* chrootdir) use_syslog?"syslog":(filename&&filename[0]?filename:"stderr")); lock_quick_lock(&log_lock); } - if(logfile && logfile != stderr) - fclose(logfile); + if(logfile && logfile != stderr) { + FILE* cl = logfile; + logfile = NULL; /* set to NULL before it is closed, so that + other threads have a valid logfile or NULL */ + fclose(cl); + } #ifdef HAVE_SYSLOG_H if(logging_to_syslog) { closelog(); |