done = true;
if ((r = cg_enumerate_processes(controller, path, &f)) < 0) {
- if (ret >= 0)
+ if (ret >= 0 && r != -ENOENT)
ret = r;
goto finish;
/* If we haven't killed this process yet, kill
* it */
- if (kill(pid, sig) < 0 && errno != ESRCH) {
- if (ret >= 0)
+ if (kill(pid, sig) < 0) {
+ if (ret >= 0 && errno != ESRCH)
ret = -errno;
} else if (ret == 0)
ret = 1;
ret = cg_kill(controller, path, sig, ignore_self);
if ((r = cg_enumerate_subgroups(controller, path, &d)) < 0) {
- if (ret >= 0)
+ if (ret >= 0 && r != -ENOENT)
ret = r;
goto finish;
if (rem)
if ((r = cg_rmdir(controller, path)) < 0) {
- if (ret >= 0)
+ if (ret >= 0 && r != -ENOENT)
ret = r;
}
done = true;
if ((r = cg_enumerate_tasks(controller, from, &f)) < 0) {
- if (ret >= 0)
+ if (ret >= 0 && r != -ENOENT)
ret = r;
goto finish;
continue;
if ((r = cg_attach(controller, to, pid)) < 0) {
- if (ret >= 0)
+ if (ret >= 0 && r != -ESRCH)
ret = r;
} else if (ret == 0)
ret = 1;
ret = cg_migrate(controller, from, to, ignore_self);
if ((r = cg_enumerate_subgroups(controller, from, &d)) < 0) {
- if (ret >= 0)
+ if (ret >= 0 && r != -ENOENT)
ret = r;
goto finish;
}
if (rem)
if ((r = cg_rmdir(controller, from)) < 0) {
- if (ret >= 0)
+ if (ret >= 0 && r != -ENOENT)
ret = r;
}
r = rm_rf(fs, true, delete_root);
free(fs);
- return r;
+ return r == -ENOENT ? 0 : r;
}
int cg_delete(const char *controller, const char *path) {
r = cg_migrate_recursive(controller, path, parent, false, true);
free(parent);
- return r;
+ return r == -ENOENT ? 0 : r;
}
int cg_create(const char *controller, const char *path) {
f = fopen(fs, "re");
free(fs);
+ if (!f)
+ return errno == ENOENT ? -ESRCH : -errno;
+
cs = strlen(controller);
while (!feof(f)) {
assert(path);
if ((r = cg_enumerate_tasks(controller, path, &f)) < 0)
- return r;
+ return r == -ENOENT ? 1 : r;
while ((r = cg_read_pid(f, &pid)) > 0) {
return r;
if ((r = cg_enumerate_subgroups(controller, path, &d)) < 0)
- return r;
+ return r == -ENOENT ? 1 : r;
while ((r = cg_read_subgroup(d, &fn)) > 0) {
char *p = NULL;
if (!(d = fdopendir(fd))) {
close_nointr_nofail(fd);
- return -errno;
+
+ return errno == ENOENT ? 0 : -errno;
}
for (;;) {
struct stat st;
if (fstatat(fd, de->d_name, &st, AT_SYMLINK_NOFOLLOW) < 0) {
- if (ret == 0)
+ if (ret == 0 && errno != ENOENT)
ret = -errno;
continue;
}
int subdir_fd;
if ((subdir_fd = openat(fd, de->d_name, O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC)) < 0) {
- if (ret == 0)
+ if (ret == 0 && errno != ENOENT)
ret = -errno;
continue;
}
}
if (unlinkat(fd, de->d_name, AT_REMOVEDIR) < 0) {
- if (ret == 0)
+ if (ret == 0 && errno != ENOENT)
ret = -errno;
}
} else if (!only_dirs) {
if (unlinkat(fd, de->d_name, 0) < 0) {
- if (ret == 0)
+ if (ret == 0 && errno != ENOENT)
ret = -errno;
}
}