]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: send timed out test SIGQUIT before SIGKILL
authorRuss Cox <rsc@golang.org>
Wed, 31 Jul 2013 02:52:10 +0000 (22:52 -0400)
committerRuss Cox <rsc@golang.org>
Wed, 31 Jul 2013 02:52:10 +0000 (22:52 -0400)
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

src/cmd/go/signal_notunix.go
src/cmd/go/signal_unix.go
src/cmd/go/test.go

index ef13c19195408683c5021c9e2bc38175c19fbb0b..29aa9d8c209ada3ee07d17dbb1e623b98bc6e379 100644 (file)
@@ -11,3 +11,7 @@ import (
 )
 
 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
index 489a73b83b4c223a8c2862da30473871f270e7b4..124f356bf82d6e7ad1470c90053572d7e77b2da8 100644 (file)
@@ -12,3 +12,7 @@ import (
 )
 
 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
index e51b5a45d165ce0baa7017d62aa2ec22b0257634..c197007c43686d7de2899712b1e91d061f61a01a 100644 (file)
@@ -896,10 +896,23 @@ func (b *builder) runTest(a *action) error {
                go func() {
                        done <- cmd.Wait()
                }()
+       Outer:
                select {
                case err = <-done:
                        // ok
                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()
                        err = <-done
                        fmt.Fprintf(&buf, "*** Test killed: ran too long (%v).\n", testKillTimeout)