diff --git a/cmd_windows.go b/cmd_windows.go index fca6c2f..d035062 100644 --- a/cmd_windows.go +++ b/cmd_windows.go @@ -19,5 +19,8 @@ func terminateProcess(pid int) error { } func setProcessGroupID(cmd *exec.Cmd) { - cmd.SysProcAttr = &syscall.SysProcAttr{} + // Set create new process group so the cmd and all its children become a new + // process group. This allows Stop to SIGTERM the cmd's process group + // without killing this process (i.e. this code here). + cmd.SysProcAttr = &syscall.SysProcAttr{CreationFlags: syscall.CREATE_NEW_PROCESS_GROUP} }