systemd/journalctl-quit-on-io-error.patch

39 lines
1.4 KiB
Diff
Raw Normal View History

From 244692cbfb46df5ff79d07da8fb848a1165bd2fb Mon Sep 17 00:00:00 2001
From: David Herrmann <dh.herrmann@googlemail.com>
Date: Sun, 13 Jan 2013 12:28:38 +0100
Subject: [PATCH] journalctl: quit on I/O error
This makes journalctl quit on ferror() conditions on stdout. It fixes an
annoying bug if you pipe its output through 'less' and press 'q'. Without
this fix journalctl will continue reading all journal data until EOF which
can take quite some time. For instance on my machine:
david-nb ~ # time journalctl | wc -l
327240
real 1m13.039s
user 1m0.217s
sys 0m10.467s
However, expected behavior is journalctl to quit when its pager closed the
output pipe.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
---
src/journal/journalctl.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Index: systemd-195/src/journal/journalctl.c
===================================================================
--- systemd-195.orig/src/journal/journalctl.c
+++ systemd-195/src/journal/journalctl.c
@@ -1035,7 +1035,7 @@ int main(int argc, char *argv[]) {
on_tty() * OUTPUT_COLOR;
r = output_journal(stdout, j, arg_output, 0, flags);
- if (r < 0)
+ if (r < 0 || ferror(stdout))
goto finish;
need_seek = true;