chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
systemctl: return an error code is status fails
[elogind.git]
/
src
/
systemctl
/
systemctl.c
diff --git
a/src/systemctl/systemctl.c
b/src/systemctl/systemctl.c
index ee0938f239dc082a811e69699ceec267fb76f9f9..e1e4640ae8f47ef6d3419360eb73ba5f157dae92 100644
(file)
--- a/
src/systemctl/systemctl.c
+++ b/
src/systemctl/systemctl.c
@@
-1430,7
+1430,7
@@
static int list_dependencies_print(const char *name, int level, unsigned int bra
printf("%s...\n",max_len % 2 ? "" : " ");
return 0;
}
printf("%s...\n",max_len % 2 ? "" : " ");
return 0;
}
- printf("%s", draw_special_char(branches & (1 << i) ? DRAW_TREE_VERT : DRAW_TREE_SPACE));
+ printf("%s", draw_special_char(branches & (1 << i) ? DRAW_TREE_VERT
ICAL
: DRAW_TREE_SPACE));
}
len += 2;
}
len += 2;
@@
-1598,9
+1598,9
@@
static int list_dependencies_one(
state = check_one_unit(bus, *c, "activating\0active\0reloading\0", true);
if (state > 0)
state = check_one_unit(bus, *c, "activating\0active\0reloading\0", true);
if (state > 0)
- printf("%s%s%s", ansi_highlight_green(), draw_special_char(DRAW_BLACK_CIRCLE), ansi_highlight_off());
+ printf("%s%s%s
", ansi_highlight_green(), draw_special_char(DRAW_BLACK_CIRCLE), ansi_highlight_off());
else
else
- printf("%s%s%s", ansi_highlight_red(), draw_special_char(DRAW_BLACK_CIRCLE), ansi_highlight_off());
+ printf("%s%s%s
", ansi_highlight_red(), draw_special_char(DRAW_BLACK_CIRCLE), ansi_highlight_off());
r = list_dependencies_print(*c, level, branches, c[1] == NULL);
if (r < 0)
r = list_dependencies_print(*c, level, branches, c[1] == NULL);
if (r < 0)
@@
-1833,7
+1833,7
@@
static void output_machines_list(struct machine_info *machine_infos, unsigned n)
on_failed = off_failed = "";
if (circle_len > 0)
on_failed = off_failed = "";
if (circle_len > 0)
- printf("%s%s%s
", on_state, circle ? draw_special_char(DRAW_BLACK_CIRCLE) : "
", off_state);
+ printf("%s%s%s
", on_state, circle ? draw_special_char(DRAW_BLACK_CIRCLE) : "
", off_state);
if (m->is_host)
printf("%-*s (host) %s%-*s%s %s%*u%s %*u\n",
if (m->is_host)
printf("%-*s (host) %s%-*s%s %s%*u%s %*u\n",
@@
-1968,7
+1968,7
@@
static int set_default(sd_bus *bus, char **args) {
return log_oom();
if (!bus || avoid_bus()) {
return log_oom();
if (!bus || avoid_bus()) {
- r = unit_file_set_default(arg_scope, arg_root, unit,
arg_forc
e, &changes, &n_changes);
+ r = unit_file_set_default(arg_scope, arg_root, unit,
tru
e, &changes, &n_changes);
if (r < 0) {
log_error("Failed to set default target: %s", strerror(-r));
return r;
if (r < 0) {
log_error("Failed to set default target: %s", strerror(-r));
return r;
@@
-1990,7
+1990,7
@@
static int set_default(sd_bus *bus, char **args) {
"SetDefaultTarget",
&error,
&reply,
"SetDefaultTarget",
&error,
&reply,
- "sb", unit,
arg_forc
e);
+ "sb", unit,
tru
e);
if (r < 0) {
log_error("Failed to set default target: %s", bus_error_message(&error, -r));
return r;
if (r < 0) {
log_error("Failed to set default target: %s", bus_error_message(&error, -r));
return r;
@@
-3234,7
+3234,7
@@
static void print_status_info(
} else
active_on = active_off = "";
} else
active_on = active_off = "";
- printf("%s%s%s%s", active_on, draw_special_char(DRAW_BLACK_CIRCLE), active_off, strna(i->id));
+ printf("%s%s%s
%s", active_on, draw_special_char(DRAW_BLACK_CIRCLE), active_off, strna(i->id));
if (i->description && !streq_ptr(i->id, i->description))
printf(" - %s", i->description);
if (i->description && !streq_ptr(i->id, i->description))
printf(" - %s", i->description);
@@
-4285,7
+4285,7
@@
static int show_all(
_cleanup_free_ UnitInfo *unit_infos = NULL;
const UnitInfo *u;
unsigned c;
_cleanup_free_ UnitInfo *unit_infos = NULL;
const UnitInfo *u;
unsigned c;
- int r;
+ int r
, ret = 0
;
r = get_unit_list(bus, NULL, NULL, &unit_infos, 0, &reply);
if (r < 0)
r = get_unit_list(bus, NULL, NULL, &unit_infos, 0, &reply);
if (r < 0)
@@
-4307,9
+4307,11
@@
static int show_all(
r = show_one(verb, bus, p, show_properties, new_line, ellipsized);
if (r < 0)
return r;
r = show_one(verb, bus, p, show_properties, new_line, ellipsized);
if (r < 0)
return r;
+ else if (r > 0 && ret == 0)
+ ret = r;
}
}
- return
0
;
+ return
ret
;
}
static int show_system_status(sd_bus *bus) {
}
static int show_system_status(sd_bus *bus) {
@@
-4338,7
+4340,7
@@
static int show_system_status(sd_bus *bus) {
} else
on = off = "";
} else
on = off = "";
- printf("%s%s%s%s\n", on, draw_special_char(DRAW_BLACK_CIRCLE), off, arg_host ? arg_host : hn);
+ printf("%s%s%s
%s\n", on, draw_special_char(DRAW_BLACK_CIRCLE), off, arg_host ? arg_host : hn);
printf(" State: %s%s%s\n",
on, strna(mi.state), off);
printf(" State: %s%s%s\n",
on, strna(mi.state), off);
@@
-4431,7
+4433,12
@@
static int show(sd_bus *bus, char **args) {
}
}
}
}
- show_one(args[0], bus, unit, show_properties, &new_line, &ellipsized);
+ r = show_one(args[0], bus, unit, show_properties,
+ &new_line, &ellipsized);
+ if (r < 0)
+ return r;
+ else if (r > 0 && ret == 0)
+ ret = r;
}
if (!strv_isempty(patterns)) {
}
if (!strv_isempty(patterns)) {
@@
-4448,7
+4455,12
@@
static int show(sd_bus *bus, char **args) {
if (!unit)
return log_oom();
if (!unit)
return log_oom();
- show_one(args[0], bus, unit, show_properties, &new_line, &ellipsized);
+ r = show_one(args[0], bus, unit, show_properties,
+ &new_line, &ellipsized);
+ if (r < 0)
+ return r;
+ else if (r > 0 && ret == 0)
+ ret = r;
}
}
}
}
}
}
@@
-6018,13
+6030,10
@@
static int halt_parse_argv(int argc, char *argv[]) {
}
}
}
}
- if (arg_action == ACTION_REBOOT && argc == optind + 1) {
- r = write_string_file(REBOOT_PARAM_FILE, argv[optind]);
- if (r < 0) {
- log_error("Failed to write reboot param to "
- REBOOT_PARAM_FILE": %s", strerror(-r));
+ if (arg_action == ACTION_REBOOT && (argc == optind || argc == optind + 1)) {
+ r = update_reboot_param_file(argc == optind + 1 ? argv[optind] : NULL);
+ if (r < 0)
return r;
return r;
- }
} else if (optind < argc) {
log_error("Too many arguments.");
return -EINVAL;
} else if (optind < argc) {
log_error("Too many arguments.");
return -EINVAL;