]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
systemctl: is-active/failed should return 0 if at least one unit is in given state 2430/head
authorLukas Nykryn <lnykryn@redhat.com>
Mon, 25 Jan 2016 14:21:28 +0000 (15:21 +0100)
committerLukas Nykryn <lnykryn@redhat.com>
Mon, 25 Jan 2016 14:21:28 +0000 (15:21 +0100)
Previously we have return the not-found code, in the case that we found a
unit which does not belong to set active (resp. failed), which is the
opposite than what is written in man page.

src/systemctl/systemctl.c

index 0199f28eba5024720b871f18be9d0df86f2c4e7c..94c99c4d91fdb053170515823dda57986bc0e36f 100644 (file)
@@ -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) {