From 40d87f09acef2a0832128d8a4fa884cfcc5a6dda Mon Sep 17 00:00:00 2001 From: "Costa Tsaousis (ktsaou)" Date: Sun, 16 Oct 2016 19:43:40 +0300 Subject: [PATCH] properly rotate the health log file --- src/health.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/health.c b/src/health.c index 2309e26c..0097d9df 100644 --- a/src/health.c +++ b/src/health.c @@ -67,15 +67,8 @@ static inline void health_log_rotate(void) { if(link(health.log_filename, old_filename) == -1 && errno != ENOENT) error("Health: cannot move file '%s' to '%s'.", health.log_filename, old_filename); - // open it with truncate - health.log_fp = fopen(health.log_filename, "w"); - - if(health.log_fp) - fclose(health.log_fp); - else - error("Health: cannot truncate health log '%s'", health.log_filename); - - health.log_fp = NULL; + if(unlink(health.log_filename) == -1 && errno != ENOENT) + error("Health: cannot remove old alarms log file '%s'", health.log_filename); health_alarm_log_open(); } -- 2.39.2