mirror of
https://github.com/golang/go
synced 2024-11-18 10:54:40 -07:00
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>
This commit is contained in:
parent
0908fad5d5
commit
3bab4ef68d
@ -14,6 +14,7 @@ import (
|
|||||||
"os/exec"
|
"os/exec"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"cmd/pprof/internal/plugin"
|
"cmd/pprof/internal/plugin"
|
||||||
"cmd/pprof/internal/report"
|
"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 := exec.Command(args[0], append(args[1:], tempFile.Name())...)
|
||||||
viewer.Stderr = os.Stderr
|
viewer.Stderr = os.Stderr
|
||||||
if err = viewer.Start(); err == nil {
|
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 {
|
if !**interactive {
|
||||||
// In command-line mode, wait for the viewer to be closed
|
// In command-line mode, wait for the viewer to be closed
|
||||||
// before proceeding
|
// before proceeding
|
||||||
|
Loading…
Reference in New Issue
Block a user