Make sure logs are always ended with newline

This commit is contained in:
topjohnwu
2022-09-09 04:29:50 -07:00
parent 44029875a6
commit a66a3b7438
19 changed files with 76 additions and 47 deletions

View File

@@ -286,13 +286,13 @@ done:
static void switch_cgroup(const char *cgroup, int pid) {
char buf[32];
snprintf(buf, sizeof(buf), "%s/cgroup.procs", cgroup);
ssprintf(buf, sizeof(buf), "%s/cgroup.procs", cgroup);
if (access(buf, F_OK) != 0)
return;
int fd = xopen(buf, O_WRONLY | O_APPEND | O_CLOEXEC);
if (fd == -1)
return;
snprintf(buf, sizeof(buf), "%d\n", pid);
ssprintf(buf, sizeof(buf), "%d\n", pid);
xwrite(fd, buf, strlen(buf));
close(fd);
}