提交 416656bb 编写于 作者: Q Quentin Monnet 提交者: Daniel Borkmann

tools: bpftool: read from stdin when batch file name is "-"

Make bpftool read its command list from standard input when the name if
the input file is a single dash.
Signed-off-by: NQuentin Monnet <quentin.monnet@netronome.com>
Acked-by: NJakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
上级 65d538dd
......@@ -195,7 +195,10 @@ static int do_batch(int argc, char **argv)
}
NEXT_ARG();
fp = fopen(*argv, "r");
if (!strcmp(*argv, "-"))
fp = stdin;
else
fp = fopen(*argv, "r");
if (!fp) {
p_err("Can't open file (%s): %s", *argv, strerror(errno));
return -1;
......@@ -284,7 +287,8 @@ static int do_batch(int argc, char **argv)
err = 0;
}
err_close:
fclose(fp);
if (fp != stdin)
fclose(fp);
if (json_output)
jsonw_end_array(json_wtr);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册