summaryrefslogtreecommitdiff
path: root/src/systemctl
diff options
context:
space:
mode:
authorDavid Tardon <dtardon@redhat.com>2023-03-17 10:11:38 +0100
committerDavid Tardon <dtardon@redhat.com>2023-03-17 10:47:04 +0100
commitbb7c4a93ea1167b1294f86307d712d45655e9632 (patch)
tree79f531f121fd231ccc8039eb05d92724f65fb47f /src/systemctl
parent5a4711e4895e3f7091e0e4da654412232484a5ec (diff)
downloadsystemd-bb7c4a93ea1167b1294f86307d712d45655e9632.tar.gz
systemctl: always print circular deps. at the end
Before: a.target ○ └─b.target ├─... ● └─paths.target After: a.target ○ └─b.target ● ├─paths.target └─...
Diffstat (limited to 'src/systemctl')
-rw-r--r--src/systemctl/systemctl-list-dependencies.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/systemctl/systemctl-list-dependencies.c b/src/systemctl/systemctl-list-dependencies.c
index 95949ab763..1da5cf5075 100644
--- a/src/systemctl/systemctl-list-dependencies.c
+++ b/src/systemctl/systemctl-list-dependencies.c
@@ -64,6 +64,7 @@ static int list_dependencies_one(
_cleanup_strv_free_ char **deps = NULL;
int r;
+ bool circular = false;
assert(bus);
assert(name);
@@ -84,12 +85,7 @@ static int list_dependencies_one(
UnitActiveState active_state;
if (strv_contains(*units, *c)) {
- if (!arg_plain) {
- printf(" ");
- r = list_dependencies_print("...", level, branches, /* last = */ c[1] == NULL);
- if (r < 0)
- return r;
- }
+ circular = true;
continue;
}
@@ -138,7 +134,7 @@ static int list_dependencies_one(
printf("%s%s%s ", on, special_glyph(unit_active_state_to_glyph(active_state)), ansi_normal());
}
- r = list_dependencies_print(*c, level, branches, c[1] == NULL);
+ r = list_dependencies_print(*c, level, branches, /* last = */ c[1] == NULL && !circular);
if (r < 0)
return r;
@@ -149,6 +145,13 @@ static int list_dependencies_one(
}
}
+ if (circular && !arg_plain) {
+ printf(" ");
+ r = list_dependencies_print("...", level, branches, /* last = */ true);
+ if (r < 0)
+ return r;
+ }
+
if (!arg_plain)
strv_remove(*units, name);