linux-headers needed fot bpf init

This commit is contained in:
springzfx
2020-05-30 01:43:37 +08:00
parent ec9609cec8
commit dfc688b5e5

View File

@@ -59,9 +59,15 @@ void handle_events(void *cb_cookie, void *data, int data_size) {
int execsnoop() {
debug("starting execsnoop");
ebpf::BPF bpf;
auto init_res = bpf.init(BPF_PROGRAM);
if (init_res.code() != 0) {
std::cerr << init_res.msg() << std::endl;
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());
return 1;
}