properly rotate the health log file
Costa Tsaousis (ktsaou) committed
Oct 16, 2016 at 19:43 UTC
40d87f09acef2a0832128d8a4fa884cfcc5a6dda
1 file changed
+2
-9
src/health.c
+2
-9
@@ -67,15 +67,8 @@ static inline void health_log_rotate(void) {
67
if(link(health.log_filename, old_filename) == -1 && errno != ENOENT)
68
error("Health: cannot move file '%s' to '%s'.", health.log_filename, old_filename);
69
70
- // open it with truncate
71
- health.log_fp = fopen(health.log_filename, "w");
72
-
73
- if(health.log_fp)
74
- fclose(health.log_fp);
75
- else
76
- error("Health: cannot truncate health log '%s'", health.log_filename);
77
-
78
- health.log_fp = NULL;
70
+ if(unlink(health.log_filename) == -1 && errno != ENOENT)
71
+ error("Health: cannot remove old alarms log file '%s'", health.log_filename);
72
73
health_alarm_log_open();
74
}