From a61f20e1aa172e30522c65973ead5509cecf01c2 Mon Sep 17 00:00:00 2001 From: Robert Findley Date: Thu, 15 Sep 2022 10:45:13 -0400 Subject: [PATCH] internal/gocommand: tweak debugging for hanging go commands Add a TODO and wait for a shorter period of time following Kill, per post-submit advice from bcmills on CL 424075. For golang/go#54461 Change-Id: Ia0e388c0119660844dad32629ebca4f122fded12 Reviewed-on: https://go-review.googlesource.com/c/tools/+/431075 TryBot-Result: Gopher Robot Run-TryBot: Robert Findley gopls-CI: kokoro Reviewed-by: Bryan Mills --- internal/gocommand/invoke.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/internal/gocommand/invoke.go b/internal/gocommand/invoke.go index 5e445663f..2327f45b5 100644 --- a/internal/gocommand/invoke.go +++ b/internal/gocommand/invoke.go @@ -276,18 +276,21 @@ func runCmdContext(ctx context.Context, cmd *exec.Cmd) error { return err case <-time.After(time.Second): } + // Didn't shut down in response to interrupt. Kill it hard. + // TODO(rfindley): per advice from bcmills@, it may be better to send SIGQUIT + // on certain platforms, such as unix. if err := cmd.Process.Kill(); err != nil && DebugHangingGoCommands { // Don't panic here as this reliably fails on windows with EINVAL. log.Printf("error killing the Go command: %v", err) } - // See above: only wait for a minute if we're debugging hanging Go commands. + // See above: don't wait indefinitely if we're debugging hanging Go commands. if DebugHangingGoCommands { select { case err := <-resChan: return err - case <-time.After(1 * time.Minute): + case <-time.After(10 * time.Second): // a shorter wait as resChan should return quickly following Kill HandleHangingGoCommand() } }