cmd/dlv: handle ctrl-c during tracing (#3477)
Ensure we send a Halt command to stop the process being traced so that the deferred Detach can run ensuring proper cleanup upon exit. Fixes #3228
This commit is contained in:
parent
32b937c953
commit
5f01e72bb8
@ -672,6 +672,15 @@ func traceCmd(cmd *cobra.Command, args []string, conf *config.Config) int {
|
||||
}
|
||||
client := rpc2.NewClientFromConn(clientConn)
|
||||
defer client.Detach(true)
|
||||
|
||||
ch := make(chan os.Signal, 1)
|
||||
signal.Notify(ch, syscall.SIGINT)
|
||||
|
||||
go func() {
|
||||
<-ch
|
||||
client.Halt()
|
||||
}()
|
||||
|
||||
funcs, err := client.ListFunctions(regexp)
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
|
Loading…
Reference in New Issue
Block a user