From a1a1ed5bd9f74269229af95b0ebe06e963f5ac36 Mon Sep 17 00:00:00 2001 From: springzfx Date: Sat, 30 May 2020 02:02:03 +0800 Subject: [PATCH] linux-headers needed fot bpf init --- src/execsnoop.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/execsnoop.cpp b/src/execsnoop.cpp index 189a3b3..1e42d55 100644 --- a/src/execsnoop.cpp +++ b/src/execsnoop.cpp @@ -60,15 +60,11 @@ void handle_events(void *cb_cookie, void *data, int data_size) { int execsnoop() { debug("starting execsnoop"); ebpf::BPF bpf; - - try { - auto init_res = bpf.init(BPF_PROGRAM); - if (init_res.code() != 0) { - std::cerr << init_res.msg() << std::endl; - return 1; - } - } catch (exception &e) { - error("bpf init failed, maybe linux-headers not installed: %s", e.what()); + + auto init_res = bpf.init(BPF_PROGRAM); + if (init_res.code() != 0) { + error("bpf init failed, maybe linux-headers not installed"); + std::cerr << init_res.msg() << std::endl; return 1; }