]> Cypherpunks repositories - gostls13.git/commitdiff
testenv: kill subprocess if SIGQUIT doesn't do it
authorAustin Clements <austin@google.com>
Thu, 9 Dec 2021 17:51:29 +0000 (12:51 -0500)
committerAustin Clements <austin@google.com>
Sun, 12 Dec 2021 14:36:20 +0000 (14:36 +0000)
This makes testenv.RunWithTimeout first attempt to SIGQUIT the
subprocess to get a useful Go traceback, but if that doesn't work, it
sends a SIGKILL instead to make sure we tear down the subprocess. This
is potentially important for non-Go subprocesses.

For #37405.

Change-Id: I9e7e118dc5769ec3f45288a71658733bff30c9cd
Reviewed-on: https://go-review.googlesource.com/c/go/+/370702
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/internal/testenv/testenv.go

index eeb7d65a9b7d8ba9908d1ab487a5198af8570a9e..d7614b07068a00b363fa08c0e4d03fdbb2ddc44a 100644 (file)
@@ -346,6 +346,13 @@ func RunWithTimeout(t testing.TB, cmd *exec.Cmd) ([]byte, error) {
                case <-done:
                case <-time.After(time.Duration(scale) * time.Minute):
                        p.Signal(Sigquit)
+                       // If SIGQUIT doesn't do it after a little
+                       // while, kill the process.
+                       select {
+                       case <-done:
+                       case <-time.After(time.Duration(scale) * 30 * time.Second):
+                               p.Signal(os.Kill)
+                       }
                }
        }()