close logfile at exit

This commit is contained in:
folkert van heusden 2023-03-13 15:46:41 +01:00
parent 050b0f7ea5
commit d785a260d9

View file

@ -35,6 +35,8 @@ void setlog(const char *lf, const log_level_t ll_file, const log_level_t ll_scre
log_level_file = ll_file; log_level_file = ll_file;
log_level_screen = ll_screen; log_level_screen = ll_screen;
atexit(closelog);
} }
void setloguid(const int uid, const int gid) void setloguid(const int uid, const int gid)
@ -45,9 +47,11 @@ void setloguid(const int uid, const int gid)
void closelog() void closelog()
{ {
fclose(lfh); if (lfh) {
fclose(lfh);
lfh = nullptr; lfh = nullptr;
}
} }
void dolog(const log_level_t ll, const char *fmt, ...) void dolog(const log_level_t ll, const char *fmt, ...)