summaryrefslogtreecommitdiff
path: root/src/machine/machinectl.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-07-11 19:14:38 +0200
committerLennart Poettering <lennart@poettering.net>2013-07-11 19:14:38 +0200
commit9d12709626bccc0cae677a7035f62efe6aabb4ab (patch)
tree2e6efd8ece92eed8c0f9d7ada70a2a72b739a43f /src/machine/machinectl.c
parent05b23cae8ebf6fbafd23ab8a0b0cfed747745d15 (diff)
loginctl: suppress cgroup tree output if cgroup is empty
same for machinectl
Diffstat (limited to 'src/machine/machinectl.c')
-rw-r--r--src/machine/machinectl.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/machine/machinectl.c b/src/machine/machinectl.c
index cd640e76a..97c219355 100644
--- a/src/machine/machinectl.c
+++ b/src/machine/machinectl.c
@@ -36,6 +36,7 @@
#include "strv.h"
#include "unit-name.h"
#include "cgroup-show.h"
+#include "cgroup-util.h"
#include "spawn-polkit-agent.h"
static char **arg_property = NULL;
@@ -125,7 +126,7 @@ static int list_machines(DBusConnection *bus, char **args, unsigned n) {
return 0;
}
-static int show_scope_cgroup(DBusConnection *bus, const char *unit) {
+static int show_scope_cgroup(DBusConnection *bus, const char *unit, pid_t leader) {
const char *interface = "org.freedesktop.systemd1.Scope";
const char *property = "ControlGroup";
_cleanup_dbus_message_unref_ DBusMessage *reply = NULL;
@@ -177,6 +178,12 @@ static int show_scope_cgroup(DBusConnection *bus, const char *unit) {
dbus_message_iter_get_basic(&sub, &cgroup);
+ if (isempty(cgroup))
+ return 0;
+
+ if (cg_is_empty_recursive(SYSTEMD_CGROUP_CONTROLLER, cgroup, false) != 0 && leader <= 0)
+ return 0;
+
output_flags =
arg_all * OUTPUT_SHOW_ALL |
arg_full * OUTPUT_FULL_WIDTH;
@@ -187,7 +194,7 @@ static int show_scope_cgroup(DBusConnection *bus, const char *unit) {
else
c = 0;
- show_cgroup_by_path(cgroup, "\t\t ", c, false, output_flags);
+ show_cgroup_and_extra(SYSTEMD_CGROUP_CONTROLLER, cgroup, "\t\t ", c, false, &leader, leader > 0, output_flags);
return 0;
}
@@ -249,7 +256,7 @@ static void print_machine_status_info(DBusConnection *bus, MachineStatusInfo *i)
if (i->scope) {
printf("\t Unit: %s\n", i->scope);
- show_scope_cgroup(bus, i->scope);
+ show_scope_cgroup(bus, i->scope, i->leader);
}
}