From 76ecc53293b4085ec5d90f2fb84669bab15f28ce Mon Sep 17 00:00:00 2001 From: Alessandro Arzilli Date: Fri, 24 Jun 2022 15:48:42 +0200 Subject: [PATCH] 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. --- pkg/proc/native/proc_windows.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/proc/native/proc_windows.go b/pkg/proc/native/proc_windows.go index e9e94b5c..38863fef 100644 --- a/pkg/proc/native/proc_windows.go +++ b/pkg/proc/native/proc_windows.go @@ -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, }