cmd/dlv: Don't stop headless server on SIGINT on windows (go-delve#1745) (#1746)

This allows to execute and debug signal handlers in inferior.
This commit is contained in:
nd 2019-11-13 18:39:14 +01:00 committed by Derek Parker
parent c902522a8c
commit 3c26681075

@ -675,9 +675,25 @@ func execute(attachPid int, processArgs []string, conf *config.Config, coreFile
} }
ch := make(chan os.Signal, 1) ch := make(chan os.Signal, 1)
signal.Notify(ch, syscall.SIGINT) signal.Notify(ch, syscall.SIGINT)
select { if runtime.GOOS == "windows" {
case <-ch: // On windows Ctrl-C sent to inferior process is delivered
case <-disconnectChan: // as SIGINT to delve. Ignore it instead of stopping the server
// in order to be able to debug signal handlers.
go func() {
for {
select {
case <-ch:
}
}
}()
select {
case <-disconnectChan:
}
} else {
select {
case <-ch:
case <-disconnectChan:
}
} }
err = server.Stop() err = server.Stop()
if err != nil { if err != nil {