chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
bus: also take write queue into consideration in sd_bus_try_close()
[elogind.git]
/
src
/
systemctl
/
systemctl.c
diff --git
a/src/systemctl/systemctl.c
b/src/systemctl/systemctl.c
index 24a74c3bb66ffadab6b292ed01998f5d224c8133..d0a03d9f290941a91f8e76a7ebcdfe59e38a7891 100644
(file)
--- a/
src/systemctl/systemctl.c
+++ b/
src/systemctl/systemctl.c
@@
-3678,6
+3678,7
@@
static int get_unit_dbus_path_by_pid(
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
+ char *u;
int r;
r = sd_bus_call_method(
int r;
r = sd_bus_call_method(
@@
-3694,10
+3695,15
@@
static int get_unit_dbus_path_by_pid(
return r;
}
return r;
}
- r = sd_bus_message_read(reply, "o",
unit
);
+ r = sd_bus_message_read(reply, "o",
&u
);
if (r < 0)
return bus_log_parse_error(r);
if (r < 0)
return bus_log_parse_error(r);
+ u = strdup(u);
+ if (!u)
+ return log_oom();
+
+ *unit = u;
return 0;
}
return 0;
}
@@
-3743,10
+3749,10
@@
static int show_all(
}
static int cat(sd_bus *bus, char **args) {
}
static int cat(sd_bus *bus, char **args) {
+ _cleanup_free_ char *unit = NULL, *n = NULL;
int r = 0;
char **name;
int r = 0;
char **name;
-
- _cleanup_free_ char *unit = NULL, *n = NULL;
+ bool first = true;
assert(bus);
assert(args);
assert(bus);
assert(args);
@@
-3754,9
+3760,9
@@
static int cat(sd_bus *bus, char **args) {
pager_open_if_enabled();
STRV_FOREACH(name, args+1) {
pager_open_if_enabled();
STRV_FOREACH(name, args+1) {
- _cleanup_
free_ char *fragment_path =
NULL;
+ _cleanup_
bus_error_free_ sd_bus_error error = SD_BUS_ERROR_
NULL;
_cleanup_strv_free_ char **dropin_paths = NULL;
_cleanup_strv_free_ char **dropin_paths = NULL;
-
sd_bus_error error
;
+
_cleanup_free_ char *fragment_path = NULL
;
char **path;
n = unit_name_mangle(*name);
char **path;
n = unit_name_mangle(*name);
@@
-3797,9
+3803,18
@@
static int cat(sd_bus *bus, char **args) {
continue;
}
continue;
}
+ if (first)
+ first = false;
+ else
+ puts("");
+
if (!isempty(fragment_path)) {
if (!isempty(fragment_path)) {
- fprintf(stdout, "# %s\n", fragment_path);
+ printf("%s# %s%s\n",
+ ansi_highlight_blue(),
+ fragment_path,
+ ansi_highlight_off());
fflush(stdout);
fflush(stdout);
+
r = sendfile_full(STDOUT_FILENO, fragment_path);
if (r < 0) {
log_warning("Failed to cat %s: %s", fragment_path, strerror(-r));
r = sendfile_full(STDOUT_FILENO, fragment_path);
if (r < 0) {
log_warning("Failed to cat %s: %s", fragment_path, strerror(-r));
@@
-3808,10
+3823,11
@@
static int cat(sd_bus *bus, char **args) {
}
STRV_FOREACH(path, dropin_paths) {
}
STRV_FOREACH(path, dropin_paths) {
-
fprintf(stdout,
"%s# %s\n",
-
isempty(fragment_path) && path == dropin_paths ? "" : "\n",
-
*path);
+
printf(
"%s# %s\n",
+ isempty(fragment_path) && path == dropin_paths ? "" : "\n",
+ *path);
fflush(stdout);
fflush(stdout);
+
r = sendfile_full(STDOUT_FILENO, *path);
if (r < 0) {
log_warning("Failed to cat %s: %s", *path, strerror(-r));
r = sendfile_full(STDOUT_FILENO, *path);
if (r < 0) {
log_warning("Failed to cat %s: %s", *path, strerror(-r));
@@
-3820,7
+3836,7
@@
static int cat(sd_bus *bus, char **args) {
}
}
}
}
- return r;
+ return r
< 0 ? r : 0
;
}
static int show(sd_bus *bus, char **args) {
}
static int show(sd_bus *bus, char **args) {
@@
-3870,8
+3886,10
@@
static int show(sd_bus *bus, char **args) {
} else {
/* Interpret as PID */
r = get_unit_dbus_path_by_pid(bus, id, &unit);
} else {
/* Interpret as PID */
r = get_unit_dbus_path_by_pid(bus, id, &unit);
- if (r < 0)
+ if (r < 0)
{
ret = r;
ret = r;
+ continue;
+ }
}
show_one(args[0], bus, unit, show_properties, &new_line, &ellipsized);
}
show_one(args[0], bus, unit, show_properties, &new_line, &ellipsized);
@@
-4834,7
+4852,8
@@
static int systemctl_help(void) {
" --root=PATH Enable unit files in the specified root directory\n"
" -n --lines=INTEGER Number of journal entries to show\n"
" -o --output=STRING Change journal output mode (short, short-monotonic,\n"
" --root=PATH Enable unit files in the specified root directory\n"
" -n --lines=INTEGER Number of journal entries to show\n"
" -o --output=STRING Change journal output mode (short, short-monotonic,\n"
- " verbose, export, json, json-pretty, json-sse, cat)\n\n"
+ " verbose, export, json, json-pretty, json-sse, cat)\n"
+ " --plain Print unit dependencies as a list instead of a tree\n\n"
"Unit Commands:\n"
" list-units [PATTERN...] List loaded units\n"
" list-sockets [PATTERN...] List loaded sockets ordered by address\n"
"Unit Commands:\n"
" list-units [PATTERN...] List loaded units\n"
" list-sockets [PATTERN...] List loaded sockets ordered by address\n"