495d3acc7b
Re-exec the test binary as a thin wrapper that holds a pipe inherited from the test. When the test goes away (any reason, including SIGKILL, panic, or OOM), the kernel closes the pipe write end; the wrapper sees EOF and SIGKILLs itself, taking QEMU and its children with it. Updates #13038 Change-Id: Ib2151098193551396c1d7bb51b07da3bd6b2cfb4 Signed-off-by: Fernando Serboncini <fserb@tailscale.com>
21 lines
435 B
Go
21 lines
435 B
Go
// Copyright (c) Tailscale Inc & contributors
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
package vmtest
|
|
|
|
import (
|
|
"os"
|
|
"os/exec"
|
|
)
|
|
|
|
// Stubs for Windows: no parent-death watcher, no process-group kill.
|
|
// The test still launches QEMU; cleanup just kills the single process.
|
|
|
|
func killWithParent(cmd *exec.Cmd) (*os.File, error) {
|
|
return os.Open(os.DevNull)
|
|
}
|
|
|
|
func killProcessTree(cmd *exec.Cmd) error {
|
|
return cmd.Process.Kill()
|
|
}
|