Check return value from rename(), fall back to truncate() on error

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson committed 2018-01-23 11:39:50 +01:00
1 parent a84bb9042f
commit 658fb9b037
1 file changed
+3 -1
+3 -1
View File
@@ -86,7 +86,9 @@ static int logrotate(char *file, int num, off_t sz)
} }
} }
rename(file, nfile); if (rename(file, nfile))
(void)truncate(file, 0);
else
create(file, st.st_mode, st.st_uid, st.st_gid); create(file, st.st_mode, st.st_uid, st.st_gid);
} else { } else {
if (truncate(file, 0)) if (truncate(file, 0))