chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
generators: rework mount generators
[elogind.git]
/
src
/
shared
/
pager.c
diff --git
a/src/shared/pager.c
b/src/shared/pager.c
index 488a12c763839f156471d1b56606fae5f06b8188..55b13d6ff63ecbf80198b5d9144c12fa5474320d 100644
(file)
--- a/
src/shared/pager.c
+++ b/
src/shared/pager.c
@@
-32,19
+32,22
@@
static pid_t pager_pid = 0;
static pid_t pager_pid = 0;
-
_noreturn_
static void pager_fallback(void) {
+
noreturn
static void pager_fallback(void) {
ssize_t n;
ssize_t n;
+
do {
n = splice(STDIN_FILENO, NULL, STDOUT_FILENO, NULL, 64*1024, 0);
} while (n > 0);
do {
n = splice(STDIN_FILENO, NULL, STDOUT_FILENO, NULL, 64*1024, 0);
} while (n > 0);
+
if (n < 0) {
log_error("Internal pager failed: %m");
_exit(EXIT_FAILURE);
}
if (n < 0) {
log_error("Internal pager failed: %m");
_exit(EXIT_FAILURE);
}
+
_exit(EXIT_SUCCESS);
}
_exit(EXIT_SUCCESS);
}
-int pager_open(
voi
d) {
+int pager_open(
bool jump_to_en
d) {
int fd[2];
const char *pager;
pid_t parent_pid;
int fd[2];
const char *pager;
pid_t parent_pid;
@@
-81,11
+84,17
@@
int pager_open(void) {
/* In the child start the pager */
if (pager_pid == 0) {
/* In the child start the pager */
if (pager_pid == 0) {
+ const char* less_opts;
dup2(fd[0], STDIN_FILENO);
close_pipe(fd);
dup2(fd[0], STDIN_FILENO);
close_pipe(fd);
- setenv("LESS", "FRSX", 0);
+ less_opts = getenv("SYSTEMD_LESS");
+ if (!less_opts)
+ less_opts = "FRSXMK";
+ if (jump_to_end)
+ less_opts = strappenda(less_opts, " +G");
+ setenv("LESS", less_opts, 1);
/* Make sure the pager goes away when the parent dies */
if (prctl(PR_SET_PDEATHSIG, SIGTERM) < 0)
/* Make sure the pager goes away when the parent dies */
if (prctl(PR_SET_PDEATHSIG, SIGTERM) < 0)