diff options
author | Lennart Poettering <lennart@poettering.net> | 2015-08-28 00:13:34 +0200 |
---|---|---|
committer | Sven Eden <yamakuzure@gmx.net> | 2017-03-14 10:19:06 +0100 |
commit | c08fa87433a5cb3fefefcadb570d03fc6f83dfbb (patch) | |
tree | ed2d6a325dd6dbb4baad663585c28b150384b184 /src/shared | |
parent | 2fa742f34291f19d73e6c8d575f97946b8c941e7 (diff) |
pager: also redirect stderr
It's really confusing if stdout goes to the pager, but stderr is written
directly to the screen. Hence, make sure both stdout and stderr are
passed to the pager when doing autopaging.
Diffstat (limited to 'src/shared')
-rw-r--r-- | src/shared/pager.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/shared/pager.c b/src/shared/pager.c index d6474030c..1c1cf1605 100644 --- a/src/shared/pager.c +++ b/src/shared/pager.c @@ -129,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; @@ -141,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; |