[systemd-devel] [PATCH] journalctl: quit on I/O error
Lennart Poettering
lennart at poettering.net
Tue Jan 15 11:59:28 PST 2013
On Sun, 13.01.13 12:28, David Herrmann (dh.herrmann at googlemail.com) wrote:
> 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:
Applied! Thanks!
>
> 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 at googlemail.com>
> ---
> src/journal/journalctl.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c
> index a74d43b..45543a5 100644
> --- a/src/journal/journalctl.c
> +++ b/src/journal/journalctl.c
> @@ -1077,7 +1077,7 @@ int main(int argc, char *argv[]) {
> arg_catalog * OUTPUT_CATALOG;
>
> r = output_journal(stdout, j, arg_output, 0, flags);
> - if (r < 0)
> + if (r < 0 || ferror(stdout))
> goto finish;
>
> need_seek = true;
Lennart
--
Lennart Poettering - Red Hat, Inc.
More information about the systemd-devel
mailing list