Commit 57933b86 authored by Russ Cox's avatar Russ Cox

cmd/go: send timed out test SIGQUIT before SIGKILL

There is a chance that the SIGQUIT will make the test process
dump its stacks as part of exiting, which would be nice for
finding out what it is doing.

Right now the builders are occasionally timing out running
the runtime test. I hope this will give us some information
about the state of the runtime.

R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/12041051
parent 4042b777
...@@ -11,3 +11,7 @@ import ( ...@@ -11,3 +11,7 @@ import (
) )
var signalsToIgnore = []os.Signal{os.Interrupt} var signalsToIgnore = []os.Signal{os.Interrupt}
// signalTrace is the signal to send to make a Go program
// crash with a stack trace.
var signalTrace os.Signal = nil
...@@ -12,3 +12,7 @@ import ( ...@@ -12,3 +12,7 @@ import (
) )
var signalsToIgnore = []os.Signal{os.Interrupt, syscall.SIGQUIT} var signalsToIgnore = []os.Signal{os.Interrupt, syscall.SIGQUIT}
// signalTrace is the signal to send to make a Go program
// crash with a stack trace.
var signalTrace os.Signal = syscall.SIGQUIT
...@@ -896,10 +896,23 @@ func (b *builder) runTest(a *action) error { ...@@ -896,10 +896,23 @@ func (b *builder) runTest(a *action) error {
go func() { go func() {
done <- cmd.Wait() done <- cmd.Wait()
}() }()
Outer:
select { select {
case err = <-done: case err = <-done:
// ok // ok
case <-tick.C: case <-tick.C:
if signalTrace != nil {
// Send a quit signal in the hope that the program will print
// a stack trace and exit. Give it five seconds before resorting
// to Kill.
cmd.Process.Signal(signalTrace)
select {
case err = <-done:
fmt.Fprintf(&buf, "*** Test killed with %v: ran too long (%v).\n", signalTrace, testKillTimeout)
break Outer
case <-time.After(5 * time.Second):
}
}
cmd.Process.Kill() cmd.Process.Kill()
err = <-done err = <-done
fmt.Fprintf(&buf, "*** Test killed: ran too long (%v).\n", testKillTimeout) fmt.Fprintf(&buf, "*** Test killed: ran too long (%v).\n", testKillTimeout)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment