snprintf(mem_max_str, sizeof(mem_max_str), "%zu", nsjconf->cgroup_mem_max);
snprintf(fname, sizeof(fname), "%s/memory.limit_in_bytes", mem_cgroup_path);
LOG_D("Setting '%s' to '%s'", fname, mem_max_str);
- if (utilWriteBufToFile(fname, mem_max_str, strlen(mem_max_str), O_WRONLY)
- == false) {
+ if (!utilWriteBufToFile(
+ fname, mem_max_str, strlen(mem_max_str), O_WRONLY | O_CLOEXEC)) {
LOG_E("Could not update memory cgroup max limit");
return false;
}
*/
snprintf(fname, sizeof(fname), "%s/memory.oom_control", mem_cgroup_path);
LOG_D("Writting '0' '%s'", fname);
- if (utilWriteBufToFile(fname, "0", strlen("0"), O_WRONLY) == false) {
+ if (!utilWriteBufToFile(fname, "0", strlen("0"), O_WRONLY | O_CLOEXEC)) {
LOG_E("Could not update memory cgroup oom control");
return false;
}
snprintf(pid_str, sizeof(pid_str), "%d", (int)pid);
snprintf(fname, sizeof(fname), "%s/tasks", mem_cgroup_path);
LOG_D("Adding PID='%s' to '%s'", pid_str, fname);
- if (utilWriteBufToFile(fname, pid_str, strlen(pid_str), O_WRONLY) == false) {
+ if (!utilWriteBufToFile(fname, pid_str, strlen(pid_str), O_WRONLY | O_CLOEXEC)) {
LOG_E("Could not update memory cgroup task list");
return false;
}
snprintf(pids_max_str, sizeof(pids_max_str), "%zu", nsjconf->cgroup_pids_max);
snprintf(fname, sizeof(fname), "%s/pids.max", pids_cgroup_path);
LOG_D("Setting '%s' to '%s'", fname, pids_max_str);
- if (utilWriteBufToFile(fname, pids_max_str, strlen(pids_max_str), O_WRONLY)
- == false) {
+ if (!utilWriteBufToFile(
+ fname, pids_max_str, strlen(pids_max_str), O_WRONLY | O_CLOEXEC)) {
LOG_E("Could not update pids cgroup max limit");
return false;
}
snprintf(pid_str, sizeof(pid_str), "%d", (int)pid);
snprintf(fname, sizeof(fname), "%s/tasks", pids_cgroup_path);
LOG_D("Adding PID='%s' to '%s'", pid_str, fname);
- if (utilWriteBufToFile(fname, pid_str, strlen(pid_str), O_WRONLY) == false) {
+ if (!utilWriteBufToFile(fname, pid_str, strlen(pid_str), O_WRONLY | O_CLOEXEC)) {
LOG_E("Could not update pids cgroup task list");
return false;
}
char fname[PATH_MAX];
snprintf(fname, sizeof(fname), "/proc/%d/setgroups", pid);
const char* denystr = "deny";
- if (utilWriteBufToFile(fname, denystr, strlen(denystr), O_WRONLY) == false) {
+ if (!utilWriteBufToFile(fname, denystr, strlen(denystr), O_WRONLY | O_CLOEXEC)) {
LOG_E("utilWriteBufToFile('%s', '%s') failed", fname, denystr);
return false;
}
}
LOG_D("Writing '%s' to '%s'", map, fname);
- if (utilWriteBufToFile(fname, map, strlen(map), O_WRONLY) == false) {
+ if (!utilWriteBufToFile(fname, map, strlen(map), O_WRONLY | O_CLOEXEC)) {
LOG_E("utilWriteBufToFile('%s', '%s') failed", fname, map);
return false;
}
}
LOG_D("Writing '%s' to '%s'", map, fname);
- if (utilWriteBufToFile(fname, map, strlen(map), O_WRONLY) == false) {
+ if (!utilWriteBufToFile(fname, map, strlen(map), O_WRONLY | O_CLOEXEC)) {
LOG_E("utilWriteBufToFile('%s', '%s') failed", fname, map);
return false;
}