diff --git a/go/kbfs/kbfsgit/runner.go b/go/kbfs/kbfsgit/runner.go index c5f761af7057..ba343b938bdb 100644 --- a/go/kbfs/kbfsgit/runner.go +++ b/go/kbfs/kbfsgit/runner.go @@ -488,6 +488,7 @@ func (r *runner) printStageStart(ctx context.Context, ctx, "Couldn't create CPU profile: %s", cpuProfName) cpuProfPath = "" } else { + defer f.Close() err := pprof.StartCPUProfile(f) if err != nil { r.log.CDebugf(ctx, "Couldn't start CPU profile: %+v", err) diff --git a/go/service/main.go b/go/service/main.go index 40f3058813e0..09b3b7f5f1ff 100644 --- a/go/service/main.go +++ b/go/service/main.go @@ -1420,6 +1420,7 @@ func (d *Service) startProfile() { d.G().Log.Warning("error creating cpu profile: %s", err) } else { d.G().Log.Debug("+ starting service cpu profile in %s", cpu) + defer f.Close() err := pprof.StartCPUProfile(f) if err != nil { d.G().Log.Warning("error starting CPU profile: %s", err) diff --git a/go/tools/sigchain/main.go b/go/tools/sigchain/main.go index 991bd4d11dc5..1b20e40aee2c 100644 --- a/go/tools/sigchain/main.go +++ b/go/tools/sigchain/main.go @@ -91,6 +91,7 @@ func main() { if err != nil { log.Fatal(err) } + defer f.Close() if err := pprof.StartCPUProfile(f); err != nil { errout(err.Error()) }