diff options
| author | Austin Clements <austin@google.com> | 2021-12-09 12:51:29 -0500 |
|---|---|---|
| committer | Austin Clements <austin@google.com> | 2021-12-12 14:36:20 +0000 |
| commit | cc795a01dcec7c97044b31571af88ac98310f2b3 (patch) | |
| tree | 38ebc425147dfb096079cd4acdb01fdf1a9a0702 /src/internal/testenv | |
| parent | 6b8977372263504535cad6e880ffca156bdfdf68 (diff) | |
| download | go-cc795a01dcec7c97044b31571af88ac98310f2b3.tar.xz | |
testenv: kill subprocess if SIGQUIT doesn't do it
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>
Diffstat (limited to 'src/internal/testenv')
| -rw-r--r-- | src/internal/testenv/testenv.go | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/internal/testenv/testenv.go b/src/internal/testenv/testenv.go index eeb7d65a9b..d7614b0706 100644 --- a/src/internal/testenv/testenv.go +++ b/src/internal/testenv/testenv.go @@ -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) + } } }() |
