You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gosuv/old/vendor/github.com/codeskyblue/kexec/kexec_windows.go

34 lines
627 B

package kexec
import (
"os"
"os/exec"
"strconv"
)
func Command(name string, arg ...string) *KCommand {
return &KCommand{
Cmd: exec.Command(name, arg...),
}
}
func CommandString(command string) *KCommand {
cmd := exec.Command("cmd", "/c", command)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
return &KCommand{
Cmd: cmd,
}
}
func (p *KCommand) Terminate(sig os.Signal) (err error) {
if p.Process == nil {
return nil
}
pid := p.Process.Pid
c := exec.Command("taskkill", "/t", "/f", "/pid", strconv.Itoa(pid))
c.Stdout = os.Stdout
c.Stderr = os.Stderr
return c.Run()
}