proc/native: fix Ctrl-C handling on non-headless instances on windows (#3039)

In non-headless instances Ctrl-C should pause the process, not
terminate it. To make this work on Windows we have to pass the
syscall.CREATE_NEW_PROCESS_GROUP flag to os.StartProcess.
This commit is contained in:
Alessandro Arzilli 2022-06-24 15:48:42 +02:00 committed by GitHub
parent db3e5ef2cd
commit 76ecc53293
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -38,6 +38,11 @@ func Launch(cmd []string, wd string, flags proc.LaunchFlags, _ []string, _ strin
return nil, err
}
creationFlags := uint32(_DEBUG_ONLY_THIS_PROCESS)
if flags&proc.LaunchForeground == 0 {
creationFlags |= syscall.CREATE_NEW_PROCESS_GROUP
}
var p *os.Process
dbp := newProcess(0)
dbp.execPtraceFunc(func() {
@ -45,7 +50,7 @@ func Launch(cmd []string, wd string, flags proc.LaunchFlags, _ []string, _ strin
Dir: wd,
Files: []*os.File{stdin, stdout, stderr},
Sys: &syscall.SysProcAttr{
CreationFlags: _DEBUG_ONLY_THIS_PROCESS,
CreationFlags: creationFlags,
},
Env: env,
}