bpftool: Enable line buffering for stdout
PATCH v3 1/1 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.
---
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(+)
tools/bpf/bpftool/main.c +2 -0
@@ -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;
Signature · 1 line
2.25.1
Quoted 8 lines · Paul Chaignon
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 <[email protected]>Signed-off-by Paul Chaignon <[email protected]>