Skip to content

Commit a61f20e

Browse files
committed
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 <gobot@golang.org> Run-TryBot: Robert Findley <rfindley@google.com> gopls-CI: kokoro <noreply+kokoro@google.com> Reviewed-by: Bryan Mills <bcmills@google.com>
1 parent cdd6986 commit a61f20e

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

internal/gocommand/invoke.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,18 +276,21 @@ func runCmdContext(ctx context.Context, cmd *exec.Cmd) error {
276276
return err
277277
case <-time.After(time.Second):
278278
}
279+
279280
// Didn't shut down in response to interrupt. Kill it hard.
281+
// TODO(rfindley): per advice from bcmills@, it may be better to send SIGQUIT
282+
// on certain platforms, such as unix.
280283
if err := cmd.Process.Kill(); err != nil && DebugHangingGoCommands {
281284
// Don't panic here as this reliably fails on windows with EINVAL.
282285
log.Printf("error killing the Go command: %v", err)
283286
}
284287

285-
// See above: only wait for a minute if we're debugging hanging Go commands.
288+
// See above: don't wait indefinitely if we're debugging hanging Go commands.
286289
if DebugHangingGoCommands {
287290
select {
288291
case err := <-resChan:
289292
return err
290-
case <-time.After(1 * time.Minute):
293+
case <-time.After(10 * time.Second): // a shorter wait as resChan should return quickly following Kill
291294
HandleHangingGoCommand()
292295
}
293296
}

0 commit comments

Comments
 (0)