]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
cgclear: fixed exit code with -e option
authorJan Safranek <jsafrane@redhat.com>
Tue, 6 Dec 2011 15:06:58 +0000 (16:06 +0100)
committerJan Safranek <jsafrane@redhat.com>
Fri, 16 Dec 2011 12:51:40 +0000 (13:51 +0100)
cgclear -e is supposed to clear only empty groups. This works fine, but
when a non-empty group is being cleared, cgclear displays an error and
returns nozero exit code.

It should be silent and return zero exit code, because stumbling upon a
nonempty group is perfectly fine and not an error.

Signed-off-by: Jan Safranek <jsafrane@redhat.com>
src/api.c
src/tools/cgclear.c

index 20ebf84c46befa9459955c603fd52eb229a64ebe..72333194b487856b5055cd008ecd9a83acdefdb2 100644 (file)
--- a/src/api.c
+++ b/src/api.c
@@ -1927,7 +1927,8 @@ static int cg_delete_cgroup_controller(char *cgroup_name, char *controller,
        ret = rmdir(path);
        if (ret == 0 || errno == ENOENT)
                return 0;
-       if (errno == EBUSY)
+
+       if ((flags & CGFLAG_DELETE_EMPTY_ONLY) && (errno == EBUSY))
                return ECGNONEMPTY;
 
        last_errno = errno;
index 1dc3e96fdbe423dd2afebd42621f21a424c4a0b0..7580403a8ee324659880653861cfa889b2f9768d 100644 (file)
@@ -119,7 +119,7 @@ int main(int argc, char *argv[])
                for (i = cfg_files.count-1; i >= 0 ; i--) {
                        ret = cgroup_config_unload_config(cfg_files.items[i],
                                        flags);
-                       if (ret) {
+                       if (ret && ret != ECGNONEMPTY) {
                                report_error(ret, argv[0]);
                                if (!error)
                                        error = ret;