aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/pprof
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2015-07-22 17:48:49 -0400
committerRuss Cox <rsc@golang.org>2015-07-23 03:51:39 +0000
commit3bab4ef68da5334a1aac558ec7bee53f6bf15cfc (patch)
tree89d8bc3b3e21008706c278cba39df3cf6f121e19 /src/cmd/pprof
parent0908fad5d509220a80b919a38feb8b388d005b10 (diff)
downloadgo-3bab4ef68da5334a1aac558ec7bee53f6bf15cfc.tar.gz
go-3bab4ef68da5334a1aac558ec7bee53f6bf15cfc.zip
cmd/pprof: fix race between viewer and web command
Fixes #11729. Change-Id: I6e5e23169ac1368afcbd016ed544a710aa045326 Reviewed-on: https://go-review.googlesource.com/12553 Reviewed-by: Rob Pike <r@golang.org>
Diffstat (limited to 'src/cmd/pprof')
-rw-r--r--src/cmd/pprof/internal/commands/commands.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/cmd/pprof/internal/commands/commands.go b/src/cmd/pprof/internal/commands/commands.go
index 9570cd0440..9aeee5762e 100644
--- a/src/cmd/pprof/internal/commands/commands.go
+++ b/src/cmd/pprof/internal/commands/commands.go
@@ -14,6 +14,7 @@ import (
"os/exec"
"runtime"
"strings"
+ "time"
"cmd/pprof/internal/plugin"
"cmd/pprof/internal/report"
@@ -224,6 +225,11 @@ func invokeVisualizer(interactive **bool, format PostProcessor, suffix string, v
viewer := exec.Command(args[0], append(args[1:], tempFile.Name())...)
viewer.Stderr = os.Stderr
if err = viewer.Start(); err == nil {
+ // The viewer might just send a message to another program
+ // to open the file. Give that program a little time to open the
+ // file before we remove it.
+ time.Sleep(1 * time.Second)
+
if !**interactive {
// In command-line mode, wait for the viewer to be closed
// before proceeding