1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-26 03:22:00 +03:00

systemctl: don't show cgroup field for a unit if cgroup is empty

This commit is contained in:
Lennart Poettering 2012-12-23 11:56:13 +01:00
parent 81dc4bde12
commit b08121d004
4 changed files with 19 additions and 7 deletions

View File

@ -335,7 +335,7 @@ int show_cgroup_and_extra(const char *controller, const char *path, const char *
int show_cgroup_and_extra_by_spec(const char *spec, const char *prefix, unsigned n_columns, bool kernel_threads, bool all, const pid_t extra_pids[], unsigned n_extra_pids) {
int r;
char *controller, *path;
_cleanup_free_ char *controller = NULL, *path = NULL;
assert(spec);
@ -343,9 +343,5 @@ int show_cgroup_and_extra_by_spec(const char *spec, const char *prefix, unsigned
if (r < 0)
return r;
r = show_cgroup_and_extra(controller, path, prefix, n_columns, kernel_threads, all, extra_pids, n_extra_pids);
free(controller);
free(path);
return r;
return show_cgroup_and_extra(controller, path, prefix, n_columns, kernel_threads, all, extra_pids, n_extra_pids);
}

View File

@ -934,6 +934,20 @@ int cg_is_empty(const char *controller, const char *path, bool ignore_self) {
return !found;
}
int cg_is_empty_by_spec(const char *spec, bool ignore_self) {
int r;
_cleanup_free_ char *controller = NULL, *path = NULL;
assert(spec);
r = cg_split_spec(spec, &controller, &path);
if (r < 0)
return r;
return cg_is_empty(controller, path, ignore_self);
}
int cg_is_empty_recursive(const char *controller, const char *path, bool ignore_self) {
int r;
DIR *d = NULL;

View File

@ -65,6 +65,7 @@ int cg_set_task_access(const char *controller, const char *path, mode_t mode, ui
int cg_install_release_agent(const char *controller, const char *agent);
int cg_is_empty(const char *controller, const char *path, bool ignore_self);
int cg_is_empty_by_spec(const char *spec, bool ignore_self);
int cg_is_empty_recursive(const char *controller, const char *path, bool ignore_self);
int cg_get_user_path(char **path);

View File

@ -2265,7 +2265,8 @@ static void print_status_info(UnitStatusInfo *i) {
if (i->status_text)
printf("\t Status: \"%s\"\n", i->status_text);
if (i->default_control_group) {
if (i->default_control_group &&
(i->main_pid > 0 || i->control_pid > 0 || cg_is_empty_by_spec(i->default_control_group, false) == 0)) {
unsigned c;
printf("\t CGroup: %s\n", i->default_control_group);