Files
ThothII/tools/tht/internal/compose/process_windows.go
T

30 lines
545 B
Go

//go:build windows
package compose
import (
"os/exec"
"syscall"
"time"
)
const finalTerminationBound = 2 * time.Second
const createNewProcessGroup = 0x00000200
func configureProcess(command *exec.Cmd) {
command.SysProcAttr = &syscall.SysProcAttr{CreationFlags: createNewProcessGroup}
}
func terminateProcess(command *exec.Cmd, done <-chan error) error {
if command.Process == nil {
return nil
}
_ = command.Process.Kill()
select {
case <-done:
return nil
case <-time.After(finalTerminationBound):
return ErrProcessReap
}
}