Merge pull request #6180 from claudiubelu/integration/windows-ip-leak

integration: Adds Windows equivalent for TestSandboxRemoveWithoutIPLeakage
This commit is contained in:
Kazuyoshi Kato
2022-04-25 11:27:31 -07:00
committed by GitHub
2 changed files with 155 additions and 2 deletions

View File

@@ -386,8 +386,12 @@ func KillProcess(name string) error {
}
// KillPid kills the process by pid. kill is used.
func KillPid(pid int) error { //nolint:unused
output, err := exec.Command("kill", strconv.Itoa(pid)).CombinedOutput()
func KillPid(pid int) error {
command := "kill"
if goruntime.GOOS == "windows" {
command = "tskill"
}
output, err := exec.Command(command, strconv.Itoa(pid)).CombinedOutput()
if err != nil {
return fmt.Errorf("failed to kill %d - error: %v, output: %q", pid, err, output)
}