summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/cgroup-show.c6
-rw-r--r--src/shared/pager.c19
2 files changed, 14 insertions, 11 deletions
diff --git a/src/shared/cgroup-show.c b/src/shared/cgroup-show.c
index 1a2c4b28cd..3abccdb49a 100644
--- a/src/shared/cgroup-show.c
+++ b/src/shared/cgroup-show.c
@@ -161,8 +161,7 @@ int show_cgroup_by_path(const char *path, const char *prefix, unsigned n_columns
}
if (last) {
- printf("%s%s%s\n", prefix, draw_special_char(DRAW_TREE_BRANCH),
- basename(last));
+ printf("%s%s%s\n", prefix, draw_special_char(DRAW_TREE_BRANCH), cg_unescape(basename(last)));
if (!p1) {
p1 = strappend(prefix, draw_special_char(DRAW_TREE_VERTICAL));
@@ -185,8 +184,7 @@ int show_cgroup_by_path(const char *path, const char *prefix, unsigned n_columns
show_cgroup_one_by_path(path, prefix, n_columns, !!last, kernel_threads, flags);
if (last) {
- printf("%s%s%s\n", prefix, draw_special_char(DRAW_TREE_RIGHT),
- basename(last));
+ printf("%s%s%s\n", prefix, draw_special_char(DRAW_TREE_RIGHT), cg_unescape(basename(last)));
if (!p2) {
p2 = strappend(prefix, " ");
diff --git a/src/shared/pager.c b/src/shared/pager.c
index 13f03e798b..85f8fa5b39 100644
--- a/src/shared/pager.c
+++ b/src/shared/pager.c
@@ -31,18 +31,16 @@
#include "macro.h"
#include "terminal-util.h"
#include "signal-util.h"
+#include "copy.h"
static pid_t pager_pid = 0;
noreturn static void pager_fallback(void) {
- ssize_t n;
-
- do {
- n = splice(STDIN_FILENO, NULL, STDOUT_FILENO, NULL, 64*1024, 0);
- } while (n > 0);
+ int r;
- if (n < 0) {
- log_error_errno(errno, "Internal pager failed: %m");
+ r = copy_bytes(STDIN_FILENO, STDOUT_FILENO, (off_t) -1, false);
+ if (r < 0) {
+ log_error_errno(r, "Internal pager failed: %m");
_exit(EXIT_FAILURE);
}
@@ -131,6 +129,8 @@ int pager_open(bool jump_to_end) {
/* Return in the parent */
if (dup2(fd[1], STDOUT_FILENO) < 0)
return log_error_errno(errno, "Failed to duplicate pager pipe: %m");
+ if (dup2(fd[1], STDERR_FILENO) < 0)
+ return log_error_errno(errno, "Failed to duplicate pager pipe: %m");
safe_close_pair(fd);
return 1;
@@ -143,6 +143,11 @@ void pager_close(void) {
/* Inform pager that we are done */
fclose(stdout);
+ stdout = NULL;
+
+ fclose(stderr);
+ stderr = NULL;
+
kill(pager_pid, SIGCONT);
(void) wait_for_terminate(pager_pid, NULL);
pager_pid = 0;