summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2016-01-25 11:52:22 -0500
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2016-01-25 11:52:22 -0500
commit7b213864afe455c39fa3f4365dd7149077fc3695 (patch)
tree30e63a79743c1bd737f04fb8ec3a426a14489ce6
parent147d3751d8279bcc294721ec115961e7a7565239 (diff)
parentd60f6ad0cb690d920b8acbfb545bad29554609f1 (diff)
Merge pull request #2430 from lnykryn/is-active-failed
systemctl: is-active/failed should return 0 if at least one unit is in given state Previously: [lnykryn@notas lnykryn-systemd(is-active-failed)]$ systemctl is-failed fail cups; echo $? failed active 1 now: [lnykryn@notas lnykryn-systemd(is-active-failed)]$ ./systemctl is-failed fail cups; echo $? failed active 0
-rw-r--r--src/systemctl/systemctl.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index 0199f28eba..94c99c4d91 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -3153,6 +3153,7 @@ static int check_unit_generic(int code, const char *good_states, char **args) {
sd_bus *bus;
char **name;
int r;
+ bool found = false;
r = acquire_bus(BUS_MANAGER, &bus);
if (r < 0)
@@ -3168,11 +3169,13 @@ static int check_unit_generic(int code, const char *good_states, char **args) {
state = check_one_unit(bus, *name, good_states, arg_quiet);
if (state < 0)
return state;
- if (state == 0)
- r = code;
+ if (state > 0)
+ found = true;
}
- return r;
+ /* use the given return code for the case that we won't find
+ * any unit which matches the list */
+ return found ? 0 : code;
}
static int check_unit_active(int argc, char *argv[], void *userdata) {