bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf v3] bpftool: Enable line buffering for stdout
@ 2021-12-20 21:45 Paul Chaignon
  2021-12-21  0:31 ` Yonghong Song
  0 siblings, 1 reply; 2+ messages in thread
From: Paul Chaignon @ 2021-12-20 21:45 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko; +Cc: bpf, Quentin Monnet

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 <quentin@isovalent.com>
Signed-off-by: Paul Chaignon <paul@isovalent.com>
---
Changes in v3:
  - Title changed from "bpftool: Flush tracelog output".
  - Enable line buffering for all of bpftool, as suggested by Andrii.
  - Rebased on bpf.
Changes in v2:
  - Resending to fix a format error.

 tools/bpf/bpftool/main.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/bpf/bpftool/main.c b/tools/bpf/bpftool/main.c
index 28237d7cef67..8fbcff9d557d 100644
--- a/tools/bpf/bpftool/main.c
+++ b/tools/bpf/bpftool/main.c
@@ -400,6 +400,8 @@ int main(int argc, char **argv)
 	};
 	int opt, ret;
 
+	setlinebuf(stdout);
+
 	last_do_help = do_help;
 	pretty_output = false;
 	json_output = false;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH bpf v3] bpftool: Enable line buffering for stdout
  2021-12-20 21:45 [PATCH bpf v3] bpftool: Enable line buffering for stdout Paul Chaignon
@ 2021-12-21  0:31 ` Yonghong Song
  0 siblings, 0 replies; 2+ messages in thread
From: Yonghong Song @ 2021-12-21  0:31 UTC (permalink / raw)
  To: Paul Chaignon, Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko
  Cc: bpf, Quentin Monnet



On 12/20/21 1:45 PM, Paul Chaignon wrote:
> 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 <quentin@isovalent.com>
> Signed-off-by: Paul Chaignon <paul@isovalent.com>

Acked-by: Yonghong Song <yhs@fb.com>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-12-21  0:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-20 21:45 [PATCH bpf v3] bpftool: Enable line buffering for stdout Paul Chaignon
2021-12-21  0:31 ` Yonghong Song

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).