mirror of
https://github.com/troglobit/finit.git
synced 2026-10-01 05:22:48 +07:00
Check return value from rename(), fall back to truncate() on error
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
+4
-2
@@ -86,8 +86,10 @@ static int logrotate(char *file, int num, off_t sz)
|
||||
}
|
||||
}
|
||||
|
||||
rename(file, nfile);
|
||||
create(file, st.st_mode, st.st_uid, st.st_gid);
|
||||
if (rename(file, nfile))
|
||||
(void)truncate(file, 0);
|
||||
else
|
||||
create(file, st.st_mode, st.st_uid, st.st_gid);
|
||||
} else {
|
||||
if (truncate(file, 0))
|
||||
syslog(LOG_ERR | LOG_PERROR, "Failed truncating %s during logrotate: %s", file, strerror(errno));
|
||||
|
||||
Reference in New Issue
Block a user