}
int main(int argc, char *argv[]) {
- int r = 0, retval = 1;
+ int r = 0, retval = EXIT_FAILURE;
log_parse_environment();
+ log_open();
if ((r = parse_argv(argc, argv)) < 0)
goto finish;
else if (r == 0) {
- retval = 0;
+ retval = EXIT_SUCCESS;
goto finish;
}
goto finish;
}
- if (path_startswith(p, "/cgroup")) {
+ if (path_startswith(p, "/sys/fs/cgroup")) {
printf("Working Directory %s:\n", p);
r = show_cgroup_by_path(p, NULL, 0);
- } else
- r = show_cgroup(SYSTEMD_CGROUP_CONTROLLER, "/", NULL, 0);
+ } else {
+ char *root = NULL;
+ const char *t = NULL;
+
+ if ((r = cg_get_by_pid(SYSTEMD_CGROUP_CONTROLLER, 1, &root)) < 0)
+ t = "/";
+ else {
+ if (endswith(root, "/system"))
+ root[strlen(root)-7] = 0;
+
+ t = root[0] ? root : "/";
+ }
+
+ r = show_cgroup(SYSTEMD_CGROUP_CONTROLLER, t, NULL, 0);
+ free(root);
+ }
free(p);
}
if (r < 0)
log_error("Failed to list cgroup tree: %s", strerror(-r));
- retval = 0;
+ retval = EXIT_SUCCESS;
finish: