static void usage(int status, const char *program_name)
{
if (status != 0) {
- fprintf(stderr, "Wrong input parameters,");
- fprintf(stderr, " try %s -h' for more information.\n",
- program_name);
+ err("Wrong input parameters, ");
+ err("try %s '-h' for more information.\n", program_name);
return;
}
- printf("Usage: %s [[-g] <controllers>:<path>] ", program_name);
- printf("[--sticky | --cancel-sticky] <list of pids>\n");
- printf("Move running task(s) to given cgroups\n");
- printf(" -h, --help Display this help\n");
- printf(" -g <controllers>:<path> Control group to be used ");
- printf("as target\n");
- printf(" --cancel-sticky cgred daemon change pidlist ");
- printf("and children tasks\n");
- printf(" --sticky cgred daemon does not change ");
- printf("pidlist and children tasks\n");
+
+ info("Usage: %s [[-g] <controllers>:<path>] ", program_name);
+ info("[--sticky | --cancel-sticky] <list of pids>\n");
+ info("Move running task(s) to given cgroups\n");
+ info(" -h, --help Display this help\n");
+ info(" -g <controllers>:<path> Control group to be used as target\n");
+ info(" --cancel-sticky cgred daemon change pidlist ");
+ info("and children tasks\n");
+ info(" --sticky cgred daemon does not change ");
+ info("pidlist and children tasks\n");
}
/*
ret = cgroup_change_cgroup_path(cgroup_list[i]->path, pid,
(const char *const*) cgroup_list[i]->controllers);
if (ret) {
- fprintf(stderr, "Error changing group of pid %d: %s\n",
- pid, cgroup_strerror(ret));
+ err("Error changing group of pid %d: %s\n", pid,
+ cgroup_strerror(ret));
return -1;
}
}
/* Put pid into right cgroup as per rules in /etc/cgrules.conf */
if (cgroup_get_uid_gid_from_procfs(pid, &euid, &egid)) {
- fprintf(stderr, "Error in determining euid/egid of ");
- fprintf(stderr, "pid %d\n", pid);
+ err("Error in determining euid/egid of pid %d\n", pid);
goto out;
}
ret = cgroup_get_procname_from_procfs(pid, &procname);
if (ret) {
- fprintf(stderr, "Error in determining process name of ");
- fprintf(stderr, "pid %d\n", pid);
+ err("Error in determining process name of pid %d\n", pid);
goto out;
}
/* Change the cgroup by determining the rules */
ret = cgroup_change_cgroup_flags(euid, egid, procname, pid, 0);
if (ret) {
- fprintf(stderr, "Error: change of cgroup failed for ");
- fprintf(stderr, "pid %d: %s\n", pid, cgroup_strerror(ret));
+ err("Error: change of cgroup failed for pid %d: %s\n", pid,
+ cgroup_strerror(ret));
goto out;
}
ret = 0;
ret = parse_cgroup_spec(cgroup_list, optarg,
CG_HIER_MAX);
if (ret) {
- fprintf(stderr, "cgroup controller and path ");
- fprintf(stderr, "parsing failed\n");
+ err("cgroup controller and path parsing ");
+ err("failed\n");
return -1;
}
cg_specified = 1;
/* Initialize libcg */
ret = cgroup_init();
if (ret) {
- fprintf(stderr, "%s: libcgroup initialization failed: %s\n",
- argv[0], cgroup_strerror(ret));
+ err("%s: libcgroup initialization failed: %s\n", argv[0],
+ cgroup_strerror(ret));
return ret;
}
pid = (pid_t) strtol(argv[i], &endptr, 10);
if (endptr[0] != '\0') {
/* the input argument was not a number */
- fprintf(stderr, "Error: %s is not valid pid.\n",
- argv[i]);
+ err("Error: %s is not valid pid.\n", argv[i]);
exit_code = 2;
continue;
}