From c2a37b73ed823a38f32e7b9c438e551f1fb00d86 Mon Sep 17 00:00:00 2001 From: guoguangwu Date: Mon, 2 Sep 2024 18:59:56 +0800 Subject: [PATCH] fix: close procRoot dir (#6906) Co-authored-by: Paulin Todev --- internal/component/pyroscope/java/asprof/asprof.go | 1 + 1 file changed, 1 insertion(+) diff --git a/internal/component/pyroscope/java/asprof/asprof.go b/internal/component/pyroscope/java/asprof/asprof.go index 9090792aa901..0e408e55d4a9 100644 --- a/internal/component/pyroscope/java/asprof/asprof.go +++ b/internal/component/pyroscope/java/asprof/asprof.go @@ -115,6 +115,7 @@ func (p *Profiler) CopyLib(dist *Distribution, pid int) error { if err != nil { return fmt.Errorf("failed to open proc root %s: %w", procRoot, err) } + defer procRootFile.Close() dstLibPath := strings.TrimPrefix(dist.LibPath(), "/") dstLauncherPath := strings.TrimPrefix(dist.LauncherPath(), "/") if err = writeFile(procRootFile, dstLibPath, libData, false); err != nil {