diff --git a/main.go b/main.go index 4997c3fd..61eae0bf 100644 --- a/main.go +++ b/main.go @@ -4,6 +4,7 @@ import ( "fmt" "io" "os" + "strings" "github.com/bettercap/bettercap/core" "github.com/bettercap/bettercap/log" @@ -90,8 +91,19 @@ func main() { if err != nil { if err == io.EOF { continue + } else if err.Error() == "Interrupt" { + var ans string + fmt.Printf("Are you sure you want to quit this session? y/n ") + fmt.Scan(&ans) + + if strings.ToLower(ans) == "y" { + sess.Run("exit") + os.Exit(0) + } + continue + } else { + log.Fatal("%s", err) } - log.Fatal("%s", err) } for _, cmd := range session.ParseCommands(line) { diff --git a/session/session.go b/session/session.go index f2680243..a53babe6 100644 --- a/session/session.go +++ b/session/session.go @@ -347,9 +347,8 @@ func (s *Session) startNetMon() { } func (s *Session) setupSignals() { - c := make(chan os.Signal, 1) - signal.Notify(c, os.Interrupt) - signal.Notify(c, syscall.SIGTERM) + c := make(chan os.Signal) + signal.Notify(c, os.Interrupt, syscall.SIGTERM) go func() { <-c fmt.Println()