You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ntool/nsys/cmdn/cmd_windows.go

24 lines
529 B
Go

package cmdn
import (
"os"
"os/exec"
"syscall"
)
// terminateProcess stops the command by sending its process group a SIGTERM signal.
// Stop is idempotent. An error should only be returning to the rare case that
// Stop is called immediately after the command ends but before Start can
// update its internal state.
func terminateProcess(pid int) error {
p, err := os.FindProcess(pid)
if err != nil {
return err
}
return p.Kill()
}
func setProcessGroupID(cmd *exec.Cmd) {
cmd.SysProcAttr = &syscall.SysProcAttr{}
}