trace: use standard POSIX header for basename()
[project/procd.git] / jail / cgroups.c
index 3e53dd5e71410c7ee0ac5a420b1a06b4acd13539..2d3dce4d31acc25b0c4c38643e55928f7743847f 100644 (file)
@@ -138,7 +138,7 @@ void cgroups_apply(pid_t pid)
                else if (!strncmp("pids.", ent, 5))
                        pids = true;
                else if (!strncmp("rdma.", ent, 5))
-                       pids = true;
+                       rdma = true;
        }
 
        maxlen += strlen(cgroup_path) + 2;
@@ -178,13 +178,14 @@ void cgroups_apply(pid_t pid)
                *cdir = '\0';
                snprintf(ent, maxlen, "%s/cgroup.subtree_control", cgroup_path);
                DEBUG(" * %s\n", ent);
-               if ((fd = open(ent, O_WRONLY)) == -1) {
+               if ((fd = open(ent, O_WRONLY)) < 0) {
                        ERROR("can't open %s: %m\n", ent);
                        continue;
                }
 
                if (write(fd, subtree_control, strlen(subtree_control)) == -1) {
                        ERROR("can't write to %s: %m\n", ent);
+                       close(fd);
                        continue;
                }
 
@@ -196,7 +197,7 @@ void cgroups_apply(pid_t pid)
                DEBUG("applying cgroup2 %s=\"%s\"\n", (char *)valp->avl.key, valp->val);
                snprintf(ent, maxlen, "%s/%s", cgroup_path, (char *)valp->avl.key);
                fd = open(ent, O_WRONLY);
-               if (fd == -1) {
+               if (fd < 0) {
                        ERROR("can't open %s: %m\n", ent);
                        continue;
                }