summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2018-06-25 19:03:31 +0200
committerGitHub <noreply@github.com>2018-06-25 19:03:31 +0200
commite49807606dee54e7455045ee9b1b652180c4a336 (patch)
tree2150493ce6d1c5e271ddfe595678e135f2338ff2
parentman: add comments about MTUBytes= and MACAddress= for tuntap devices (diff)
parentsystemctl: if we can't detect the system-is-running state, assume it's not ru... (diff)
downloadsystemd-e49807606dee54e7455045ee9b1b652180c4a336.tar.xz
systemd-e49807606dee54e7455045ee9b1b652180c4a336.zip
Merge pull request #9411 from poettering/systemctl-is-running-fixes
tiny systemctl fixes
-rw-r--r--src/systemctl/systemctl.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index f072ad0c31..9c6156237a 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -3673,13 +3673,20 @@ static int check_unit_generic(int code, const UnitActiveState good_states[], int
}
static int check_unit_active(int argc, char *argv[], void *userdata) {
- const UnitActiveState states[] = { UNIT_ACTIVE, UNIT_RELOADING };
+ static const UnitActiveState states[] = {
+ UNIT_ACTIVE,
+ UNIT_RELOADING,
+ };
+
/* According to LSB: 3, "program is not running" */
return check_unit_generic(EXIT_PROGRAM_NOT_RUNNING, states, ELEMENTSOF(states), strv_skip(argv, 1));
}
static int check_unit_failed(int argc, char *argv[], void *userdata) {
- const UnitActiveState states[] = { UNIT_FAILED };
+ static const UnitActiveState states[] = {
+ UNIT_FAILED,
+ };
+
return check_unit_generic(EXIT_PROGRAM_DEAD_AND_PID_EXISTS, states, ELEMENTSOF(states), strv_skip(argv, 1));
}
@@ -6584,6 +6591,7 @@ static int unit_is_enabled(int argc, char *argv[], void *userdata) {
}
static int is_system_running(int argc, char *argv[], void *userdata) {
+ _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_free_ char *state = NULL;
sd_bus *bus;
int r;
@@ -6604,12 +6612,14 @@ static int is_system_running(int argc, char *argv[], void *userdata) {
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"SystemState",
- NULL,
+ &error,
&state);
if (r < 0) {
+ log_debug_errno(r, "Failed to query system state: %s", bus_error_message(&error, r));
+
if (!arg_quiet)
puts("unknown");
- return 0;
+ return EXIT_FAILURE;
}
if (!arg_quiet)