diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2017-02-01 14:30:57 -0500 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2017-02-01 20:31:50 -0500 |
commit | bc06be753346784e19151814b5b9c01c624317f2 (patch) | |
tree | 233cc31ce5b3fc827c08a2c01fb87ea9868005dc /src/login/loginctl.c | |
parent | d3e8277d5004163c725a895778c3a9dce9ca091e (diff) | |
download | systemd-bc06be753346784e19151814b5b9c01c624317f2.tar.gz |
shared/cgroup-show: extract funtion to query unit cgroup path
…and use it where possible.
Diffstat (limited to 'src/login/loginctl.c')
-rw-r--r-- | src/login/loginctl.c | 25 |
1 files changed, 3 insertions, 22 deletions
diff --git a/src/login/loginctl.c b/src/login/loginctl.c index 4c618ed19e..1aac7ae979 100644 --- a/src/login/loginctl.c +++ b/src/login/loginctl.c @@ -240,7 +240,6 @@ static int list_seats(int argc, char *argv[], void *userdata) { sd_bus *bus = userdata; unsigned k = 0; int r; - assert(bus); assert(argv); @@ -280,35 +279,17 @@ static int list_seats(int argc, char *argv[], void *userdata) { } static int show_unit_cgroup(sd_bus *bus, const char *interface, const char *unit, pid_t leader) { + _cleanup_free_ char *cgroup = NULL; _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL; - _cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL; - _cleanup_free_ char *path = NULL; - const char *cgroup; unsigned c; int r; assert(bus); assert(unit); - path = unit_dbus_path_from_name(unit); - if (!path) - return log_oom(); - - r = sd_bus_get_property( - bus, - "org.freedesktop.systemd1", - path, - interface, - "ControlGroup", - &error, - &reply, - "s"); - if (r < 0) - return log_error_errno(r, "Failed to query ControlGroup: %s", bus_error_message(&error, r)); - - r = sd_bus_message_read(reply, "s", &cgroup); + r = show_cgroup_get_unit_path_and_warn(bus, unit, &cgroup); if (r < 0) - return bus_log_parse_error(r); + return r; if (isempty(cgroup)) return 0; |