gadgets/collect/process: Add missing Close() calls
The documentation on NewCollectionWithOptions() states that
"Omitting Collection.Close() during application shutdown is an error.",
this commit fixes that by adding this missing line.
Even if AttachIter() doesn't state we should call Close() on the
returned link, it's a good practice.
@@ -60,6 +60,7 @@ func RunCollector(enricher gadgets.DataEnricher, mntnsmap *ebpf.Map) ([]processc
if err != nil {
return nil, fmt.Errorf("failed to create BPF collection: %w", err)
}
+ defer coll.Close()
dumpTask, ok := coll.Programs[BPFIterName]
if !ok {
@@ -71,6 +72,7 @@ func RunCollector(enricher gadgets.DataEnricher, mntnsmap *ebpf.Map) ([]processc
if err != nil {
return nil, fmt.Errorf("failed to attach BPF iterator: %w", err)
}
+ defer dumpTaskIter.Close()
file, err := dumpTaskIter.Open()
if err != nil {
