From d3387e2a28cb5659499470f09942e377f27e4c03 Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Mon, 20 Jul 2015 15:34:40 +0200 Subject: [PATCH] Make sure CPU profile actually gets written before exiting --- cmd/syncthing/main.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cmd/syncthing/main.go b/cmd/syncthing/main.go index 7f513190..972bf023 100644 --- a/cmd/syncthing/main.go +++ b/cmd/syncthing/main.go @@ -672,7 +672,6 @@ func syncthingMain() { log.Fatal(err) } pprof.StartCPUProfile(f) - defer pprof.StopCPUProfile() } for _, device := range cfg.Devices() { @@ -728,6 +727,11 @@ func syncthingMain() { mainSvc.Stop() l.Okln("Exiting") + + if cpuProfile { + pprof.StopCPUProfile() + } + os.Exit(code) }