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{} }