mirror of
https://github.com/go-delve/delve.git
synced 2025-11-01 12:01:35 +08:00
Handle SIGINT
Handle SIGINT by stopping the traced program and then displaying a prompt to the user for commands. If the traced process is not running, this is a noop. Closes #30
This commit is contained in:
@ -5,6 +5,7 @@ import (
|
||||
"io"
|
||||
"os"
|
||||
"os/exec"
|
||||
"os/signal"
|
||||
"strings"
|
||||
"syscall"
|
||||
|
||||
@ -47,6 +48,16 @@ func Run(run bool, pid int, args []string) {
|
||||
}
|
||||
}
|
||||
|
||||
ch := make(chan os.Signal)
|
||||
signal.Notify(ch, syscall.SIGINT)
|
||||
go func() {
|
||||
for _ = range ch {
|
||||
if dbp.Running() {
|
||||
dbp.RequestManualStop()
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
cmds := command.DebugCommands()
|
||||
goreadline.LoadHistoryFromFile(historyFile)
|
||||
fmt.Println("Type 'help' for list of commands.")
|
||||
|
||||
Reference in New Issue
Block a user