serviceman/runner/runner_windows.go

24 lines
452 B
Go
Raw Permalink Normal View History

2019-07-03 08:11:50 +00:00
package runner
import (
"fmt"
2019-07-03 08:11:50 +00:00
"os/exec"
"strconv"
2019-07-03 09:04:28 +00:00
"syscall"
2019-07-03 08:11:50 +00:00
)
2019-07-03 09:04:28 +00:00
func backgroundCmd(cmd *exec.Cmd) {
cmd.SysProcAttr = &syscall.SysProcAttr{HideWindow: true}
}
func kill(pid int) error {
// Kill the whole processes tree (all children and grandchildren)
cmd := exec.Command("taskkill", "/pid", strconv.Itoa(pid), "/T", "/F")
b, err := cmd.CombinedOutput()
if nil != err {
return fmt.Errorf("%s: %s", err.Error(), string(b))
}
return nil
}