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:
Derek Parker
2015-01-09 16:24:33 -06:00
parent 6acb912a0c
commit bc39ddfbbc
3 changed files with 99 additions and 40 deletions

View File

@ -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.")