+ r = start_unit(bus, args);
+ if (r == EXIT_SUCCESS)
+ warn_wall(a);
+
+ return r;
+}
+
+static int check_unit_active(DBusConnection *bus, char **args) {
+ const char * const check_states[] = {
+ "active",
+ "reloading",
+ NULL
+ };
+
+ char **name;
+ int r = 3; /* According to LSB: "program is not running" */
+
+ assert(bus);
+ assert(args);
+
+ STRV_FOREACH(name, args+1) {
+ int state;
+
+ state = check_one_unit(bus, *name, (char**) check_states, arg_quiet);
+ if (state < 0)
+ return state;
+ if (state > 0)
+ r = 0;
+ }
+
+ return r;
+}
+
+static int check_unit_failed(DBusConnection *bus, char **args) {
+ const char * const check_states[] = {
+ "failed",
+ NULL
+ };
+
+ char **name;
+ int r = 1;
+
+ assert(bus);
+ assert(args);
+
+ STRV_FOREACH(name, args+1) {
+ int state;
+
+ state = check_one_unit(bus, *name, (char**) check_states, arg_quiet);
+ if (state < 0)
+ return state;
+ if (state > 0)
+ r = 0;
+ }
+
+ return r;
+}
+
+static int kill_unit(DBusConnection *bus, char **args) {
+ char **name;
+ int r = 0;
+
+ assert(bus);
+ assert(args);
+
+ if (!arg_kill_who)
+ arg_kill_who = "all";
+
+ STRV_FOREACH(name, args+1) {
+ _cleanup_free_ char *n = NULL;
+
+ n = unit_name_mangle(*name);
+ if (!n)
+ return log_oom();
+
+ r = bus_method_call_with_reply(
+ bus,
+ "org.freedesktop.systemd1",
+ "/org/freedesktop/systemd1",
+ "org.freedesktop.systemd1.Manager",
+ "KillUnit",
+ NULL,
+ NULL,
+ DBUS_TYPE_STRING, &n,
+ DBUS_TYPE_STRING, &arg_kill_who,
+ DBUS_TYPE_INT32, &arg_signal,
+ DBUS_TYPE_INVALID);
+ if (r < 0)
+ return r;
+ }
+ return 0;
+}
+
+static int set_cgroup(DBusConnection *bus, char **args) {
+ _cleanup_free_ char *n = NULL;
+ const char *method, *runtime;
+ char **argument;
+ int r;
+
+ assert(bus);
+ assert(args);
+
+ method =
+ streq(args[0], "set-cgroup") ? "SetUnitControlGroup" :
+ streq(args[0], "unset-cgroup") ? "UnsetUnitControlGroup"
+ : "UnsetUnitControlGroupAttribute";
+
+ runtime = arg_runtime ? "runtime" : "persistent";
+
+ n = unit_name_mangle(args[1]);
+ if (!n)
+ return log_oom();
+
+ STRV_FOREACH(argument, args + 2) {
+
+ r = bus_method_call_with_reply(
+ bus,
+ "org.freedesktop.systemd1",
+ "/org/freedesktop/systemd1",
+ "org.freedesktop.systemd1.Manager",
+ method,
+ NULL,
+ NULL,
+ DBUS_TYPE_STRING, &n,
+ DBUS_TYPE_STRING, argument,
+ DBUS_TYPE_STRING, &runtime,
+ DBUS_TYPE_INVALID);
+ if (r < 0)
+ return r;
+ }
+
+ return 0;