Skip to content

Commit ead1c47

Browse files
Add Windows SysProcAttr create new process group
When programs on Windows are terminated the child processes will not be killed anymore.
1 parent 9ca92cd commit ead1c47

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

cmd_windows.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,8 @@ func terminateProcess(pid int) error {
1616
}
1717

1818
func setProcessGroupID(cmd *exec.Cmd) {
19-
cmd.SysProcAttr = &syscall.SysProcAttr{}
19+
// Set create new process group so the cmd and all its children become a new
20+
// process group. This allows Stop to SIGTERM the cmd's process group
21+
// without killing this process (i.e. this code here).
22+
cmd.SysProcAttr = &syscall.SysProcAttr{CreationFlags: syscall.CREATE_NEW_PROCESS_GROUP}
2023
}

0 commit comments

Comments
 (0)