From: Ken'ichi Ohmichi Date: Thu, 16 Sep 2010 05:08:59 +0000 (+0900) Subject: Add the flag CGROUP_DAEMON_CANCEL_UNCHANGE_PROCESS. X-Git-Tag: v0.37.1~35 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9e6e993e879c29d69537e8cb5ee98e015174990c;p=thirdparty%2Flibcgroup.git Add the flag CGROUP_DAEMON_CANCEL_UNCHANGE_PROCESS. A new flag CGROUP_DAEMON_CANCEL_UNCHANGE_PROCESS cancels the unchanged process. If specifying this flag as the argument of cgroup_register_unchanged_process, a cgrulesengd daemon can move the specified process to right cgroup based on /etc/cgrules.conf. Signed-off-by: Ken'ichi Ohmichi Signed-off-by: Balbir Singh --- diff --git a/doc/man/cgclassify.1 b/doc/man/cgclassify.1 index c03003ff..2d8921bc 100644 --- a/doc/man/cgclassify.1 +++ b/doc/man/cgclassify.1 @@ -6,7 +6,7 @@ cgclassify \- move running task(s) to given cgroups .SH SYNOPSIS -\fBcgclassify\fR [\fB-g\fR <\fIcontrollers>:] [--sticky] <\fIpidlist\fR> +\fBcgclassify\fR [\fB-g\fR <\fIcontrollers>:] [--sticky | --cancel-sticky] <\fIpidlist\fR> .SH DESCRIPTION this command moves processes defined by the list @@ -41,6 +41,13 @@ children tasks. Without this option, the daemon does not change the specified \fBpidlist\fR but it changes their children tasks to the right cgroup based on \fB/etc/cgrules.conf\fR automatically. +.TP +.B --cancel-sticky +If this option is used, the daemon of service cgred (cgrulesengd +process) can change both the specified \fBpidlist\fR and their +children tasks to right cgroup based on \fB/etc/cgrules.conf\fR +automatically. + .SH FILES .LP .PD .1v diff --git a/src/tools/cgclassify.c b/src/tools/cgclassify.c index a0d047b2..31811058 100644 --- a/src/tools/cgclassify.c +++ b/src/tools/cgclassify.c @@ -93,6 +93,7 @@ out: static struct option longopts[] = { {"sticky", no_argument, NULL, 's'}, + {"cancel-sticky", no_argument, NULL, 'u'}, {0, 0, 0, 0} }; @@ -101,7 +102,7 @@ int main(int argc, char *argv[]) int ret = 0, i, exit_code = 0; pid_t pid; int cg_specified = 0; - int flag_child = 0; + int flag = 0; struct cgroup_group_spec *cgroup_list[CG_HIER_MAX]; int c; @@ -109,7 +110,7 @@ int main(int argc, char *argv[]) if (argc < 2) { fprintf(stderr, "usage is %s " "[-g :] " - "[--sticky] \n", + "[--sticky | --cancel-sticky] \n", argv[0]); exit(2); } @@ -128,7 +129,10 @@ int main(int argc, char *argv[]) cg_specified = 1; break; case 's': - flag_child |= CGROUP_DAEMON_UNCHANGE_CHILDREN; + flag |= CGROUP_DAEMON_UNCHANGE_CHILDREN; + break; + case 'u': + flag |= CGROUP_DAEMON_CANCEL_UNCHANGE_PROCESS; break; default: fprintf(stderr, "Invalid command line option\n"); @@ -148,8 +152,8 @@ int main(int argc, char *argv[]) for (i = optind; i < argc; i++) { pid = (uid_t) atoi(argv[i]); - if (flag_child) - ret = cgroup_register_unchanged_process(pid, flag_child); + if (flag) + ret = cgroup_register_unchanged_process(pid, flag); if (ret) exit_code = 1;