From: Jan Safranek Date: Tue, 6 Dec 2011 15:06:58 +0000 (+0100) Subject: cgclear: fixed exit code with -e option X-Git-Tag: v0.38~14 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=25f2a29221da9d8fc05d618603bd0d79e40fac94;p=thirdparty%2Flibcgroup.git cgclear: fixed exit code with -e option 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 --- diff --git a/src/api.c b/src/api.c index 20ebf84c..72333194 100644 --- 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; diff --git a/src/tools/cgclear.c b/src/tools/cgclear.c index 1dc3e96f..7580403a 100644 --- a/src/tools/cgclear.c +++ b/src/tools/cgclear.c @@ -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;