diff --git a/internal/driver/driver.go b/internal/driver/driver.go index bc5f3661..c2b1cd08 100644 --- a/internal/driver/driver.go +++ b/internal/driver/driver.go @@ -54,7 +54,7 @@ func PProf(eo *plugin.Options) error { } if src.HTTPHostport != "" { - return serveWebInterface(src.HTTPHostport, p, o) + return serveWebInterface(src.HTTPHostport, p, o, true) } return interactive(p, o) } diff --git a/internal/driver/webui.go b/internal/driver/webui.go index 67ae2628..08b32ccb 100644 --- a/internal/driver/webui.go +++ b/internal/driver/webui.go @@ -81,7 +81,7 @@ type webArgs struct { Top []report.TextItem } -func serveWebInterface(hostport string, p *profile.Profile, o *plugin.Options) error { +func serveWebInterface(hostport string, p *profile.Profile, o *plugin.Options, wantBrowser bool) error { host, portStr, err := net.SplitHostPort(hostport) if err != nil { return fmt.Errorf("could not split http address: %v", err) @@ -123,7 +123,9 @@ func serveWebInterface(hostport string, p *profile.Profile, o *plugin.Options) e }, } - go openBrowser("http://"+args.Hostport, o) + if wantBrowser { + go openBrowser("http://"+args.Hostport, o) + } return server(args) } diff --git a/internal/driver/webui_test.go b/internal/driver/webui_test.go index 76565eb8..94bf2a57 100644 --- a/internal/driver/webui_test.go +++ b/internal/driver/webui_test.go @@ -57,7 +57,7 @@ func TestWebInterface(t *testing.T) { Obj: fakeObjTool{}, UI: &stdUI{}, HTTPServer: creator, - }) + }, false) <-serverCreated defer server.Close()