mirror of
https://github.com/tailscale/tailscale.git
synced 2026-09-14 06:48:32 -04:00
29 lines
754 B
Go
29 lines
754 B
Go
// Copyright (c) Tailscale Inc & contributors
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
//go:build windows
|
|
|
|
package integration
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"os/exec"
|
|
"syscall"
|
|
|
|
"golang.org/x/sys/windows"
|
|
)
|
|
|
|
// setNewProcessGroup gives cmd its own process group since CTRL_BREAK targets a whole group.
|
|
func setNewProcessGroup(cmd *exec.Cmd) {
|
|
cmd.SysProcAttr = &syscall.SysProcAttr{CreationFlags: windows.CREATE_NEW_PROCESS_GROUP}
|
|
}
|
|
|
|
// interruptProcess interrupts process via CTRL_BREAK, which its Go runtime maps to SIGINT.
|
|
func interruptProcess(process *os.Process) error {
|
|
if err := windows.GenerateConsoleCtrlEvent(windows.CTRL_BREAK_EVENT, uint32(process.Pid)); err != nil {
|
|
return fmt.Errorf("GenerateConsoleCtrlEvent: %w", err)
|
|
}
|
|
return nil
|
|
}
|