diff options
author | thiagoftsm <thiagoftsm@gmail.com> | 2022-04-04 12:32:11 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-04 12:32:11 +0000 |
commit | 012f8c1d317bf15a54dc0346b6655e1e838cdfc6 (patch) | |
tree | adedfe1a40cf377e6e769a39082d0d7242be8d51 /collectors/ebpf.plugin | |
parent | c086b6611207dd6599d4375eee51e46f2e5894a5 (diff) |
Fix ebpf exit (#12590)
Diffstat (limited to 'collectors/ebpf.plugin')
-rw-r--r-- | collectors/ebpf.plugin/ebpf.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/collectors/ebpf.plugin/ebpf.c b/collectors/ebpf.plugin/ebpf.c index f73e99fdc3..b93c2dfd73 100644 --- a/collectors/ebpf.plugin/ebpf.c +++ b/collectors/ebpf.plugin/ebpf.c @@ -212,6 +212,7 @@ void clean_loaded_events() static void ebpf_exit(int sig) { close_ebpf_plugin = 1; + static int remove_pid = 0; // When both threads were not finished case I try to go in front this address, the collector will crash if (!thread_finished) { @@ -296,13 +297,19 @@ static void ebpf_exit(int sig) */ #ifdef LIBBPF_MAJOR_VERSION - if (default_btf) + if (default_btf) { btf__free(default_btf); + default_btf = NULL; + } #endif - char filename[FILENAME_MAX + 1]; - ebpf_pid_file(filename, FILENAME_MAX); - unlink(filename); + if (!remove_pid) { + remove_pid = 1; + char filename[FILENAME_MAX + 1]; + ebpf_pid_file(filename, FILENAME_MAX); + if (unlink(filename)) + error("Cannot remove PID file %s", filename); + } exit(sig); } |