2019-07-03 08:11:50 +00:00
|
|
|
package runner
|
|
|
|
|
|
|
|
import (
|
2019-07-10 07:16:45 +00:00
|
|
|
"fmt"
|
2019-07-03 08:11:50 +00:00
|
|
|
"os/exec"
|
2019-07-10 07:16:45 +00:00
|
|
|
"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}
|
|
|
|
}
|
2019-07-10 07:16:45 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
}
|