diff options
author | Zbigniew Jedrzejewski-Szmek <zbyszek@in.waw.pl> | 2012-07-20 09:06:26 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2012-07-23 17:57:11 +0200 |
commit | fafb6eccc2c9e3f8d6ce0aad9cb428f8cc402b24 (patch) | |
tree | 1cf54ff0d9fa2a6d5cf36b13d8511caa0b5fc4c8 /src/shared/pager.c | |
parent | f84b1a8c3aff81c9d80f47943e116e205c884565 (diff) |
journalctl: fix ellipsization with PAGER=cat
There are other reasons for not opening the pager then the --no-pager
or --follow options (described below). If the pager is not used,
messages must be ellipsized.
On Fri, Jul 20, 2012 at 05:42:44AM +0000, Shawn Landen wrote:
> "Pager to use when --no-pager is not given; overrides $PAGER.
> Setting this to an empty string or the value cat is equivalent to passing --no-pager."
Diffstat (limited to 'src/shared/pager.c')
-rw-r--r-- | src/shared/pager.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/shared/pager.c b/src/shared/pager.c index 6a85af33c4..36b409c070 100644 --- a/src/shared/pager.c +++ b/src/shared/pager.c @@ -44,20 +44,20 @@ _noreturn_ static void pager_fallback(void) { _exit(EXIT_SUCCESS); } -void pager_open(void) { +bool pager_open(void) { int fd[2]; const char *pager; pid_t parent_pid; if (pager_pid > 0) - return; + return false; if ((pager = getenv("SYSTEMD_PAGER")) || (pager = getenv("PAGER"))) if (!*pager || streq(pager, "cat")) - return; + return false; if (isatty(STDOUT_FILENO) <= 0) - return; + return false; /* Determine and cache number of columns before we spawn the * pager so that we get the value from the actual tty */ @@ -65,7 +65,7 @@ void pager_open(void) { if (pipe(fd) < 0) { log_error("Failed to create pager pipe: %m"); - return; + return false; } parent_pid = getpid(); @@ -74,7 +74,7 @@ void pager_open(void) { if (pager_pid < 0) { log_error("Failed to fork pager: %m"); close_pipe(fd); - return; + return false; } /* In the child start the pager */ @@ -115,10 +115,13 @@ void pager_open(void) { } /* Return in the parent */ - if (dup2(fd[1], STDOUT_FILENO) < 0) + if (dup2(fd[1], STDOUT_FILENO) < 0) { log_error("Failed to duplicate pager pipe: %m"); + return false; + } close_pipe(fd); + return true; } void pager_close(void) { |