]> git.ipfire.org Git - pakfire.git/commitdiff
cgroups: Close the FD after we removed the cgroup
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 14 Dec 2024 14:09:29 +0000 (14:09 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 14 Dec 2024 14:09:29 +0000 (14:09 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/cgroup.c

index 786f0f898d74296a106120124ab84460b23140cf..6bc1a9615b0bc208418a72481cfd5c082100ac32 100644 (file)
@@ -520,17 +520,19 @@ int pakfire_cgroup_destroy(struct pakfire_cgroup* cgroup) {
        if (r)
                return r;
 
+       // Delete the directory
+       r = unlinkat(cgroup->parent->fd, cgroup->name, AT_REMOVEDIR);
+       if (r) {
+               ERROR(cgroup->ctx, "Could not destroy cgroup %s: %m\n", cgroup->path);
+               return -errno;
+       }
+
        // Close the file descriptor
        if (cgroup->fd >= 0) {
                close(cgroup->fd);
                cgroup->fd = -EBADF;
        }
 
-       // Delete the directory
-       r = unlinkat(cgroup->parent->fd, cgroup->name, AT_REMOVEDIR);
-       if (r)
-               ERROR(cgroup->ctx, "Could not destroy cgroup: %m\n");
-
        return r;
 }