зеркало из https://github.com/golang/tools.git
internal/gocommand: show pid of process
We're almost certain that the go process shown by ps is not the one that we're waiting for in runCmdContext, but only by printing the pid can we be sure. Updates golang/go#54461 Change-Id: I1ce9580de6ee6bc4557d76c2a6b05f5a3e2eb6c2 Reviewed-on: https://go-review.googlesource.com/c/tools/+/434637 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Alan Donovan <adonovan@google.com> gopls-CI: kokoro <noreply+kokoro@google.com> Reviewed-by: Robert Findley <rfindley@google.com>
This commit is contained in:
Родитель
c5cd943077
Коммит
5214f412ae
|
@ -258,7 +258,7 @@ func runCmdContext(ctx context.Context, cmd *exec.Cmd) error {
|
|||
case err := <-resChan:
|
||||
return err
|
||||
case <-time.After(1 * time.Minute):
|
||||
HandleHangingGoCommand()
|
||||
HandleHangingGoCommand(cmd.Process)
|
||||
case <-ctx.Done():
|
||||
}
|
||||
} else {
|
||||
|
@ -291,13 +291,13 @@ func runCmdContext(ctx context.Context, cmd *exec.Cmd) error {
|
|||
case err := <-resChan:
|
||||
return err
|
||||
case <-time.After(10 * time.Second): // a shorter wait as resChan should return quickly following Kill
|
||||
HandleHangingGoCommand()
|
||||
HandleHangingGoCommand(cmd.Process)
|
||||
}
|
||||
}
|
||||
return <-resChan
|
||||
}
|
||||
|
||||
func HandleHangingGoCommand() {
|
||||
func HandleHangingGoCommand(proc *os.Process) {
|
||||
switch runtime.GOOS {
|
||||
case "linux", "darwin", "freebsd", "netbsd":
|
||||
fmt.Fprintln(os.Stderr, `DETECTED A HANGING GO COMMAND
|
||||
|
@ -330,7 +330,7 @@ See golang/go#54461 for more details.`)
|
|||
panic(fmt.Sprintf("running %s: %v", listFiles, err))
|
||||
}
|
||||
}
|
||||
panic("detected hanging go command: see golang/go#54461 for more details")
|
||||
panic(fmt.Sprintf("detected hanging go command (pid %d): see golang/go#54461 for more details", proc.Pid))
|
||||
}
|
||||
|
||||
func cmdDebugStr(cmd *exec.Cmd) string {
|
||||
|
|
Загрузка…
Ссылка в новой задаче