From: Paul Chaignon Date: Mon, 20 Dec 2021 21:45:28 +0000 (+0100) Subject: bpftool: Enable line buffering for stdout X-Git-Tag: block-5.17-2022-01-21~91^2~92^2~14 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=1a1a0b0364ad291bd8e509da104ac8b5b1afec5d;p=linux-block.git bpftool: Enable line buffering for stdout The output of bpftool prog tracelog is currently buffered, which is inconvenient when piping the output into other commands. A simple tracelog | grep will typically not display anything. This patch fixes it by enabling line buffering on stdout for the whole bpftool binary. Fixes: 30da46b5dc3a ("tools: bpftool: add a command to dump the trace pipe") Signed-off-by: Quentin Monnet Signed-off-by: Paul Chaignon Signed-off-by: Andrii Nakryiko Acked-by: Yonghong Song Link: https://lore.kernel.org/bpf/20211220214528.GA11706@Mem --- diff --git a/tools/bpf/bpftool/main.c b/tools/bpf/bpftool/main.c index 8b71500e7cb2..020e91a542d5 100644 --- a/tools/bpf/bpftool/main.c +++ b/tools/bpf/bpftool/main.c @@ -408,6 +408,8 @@ int main(int argc, char **argv) bool version_requested = false; int opt, ret; + setlinebuf(stdout); + last_do_help = do_help; pretty_output = false; json_output = false;