From c5471287980cdf22cd0872f914f95e2bcd094969 Mon Sep 17 00:00:00 2001 From: edoardottt Date: Tue, 15 Nov 2022 16:54:08 +0100 Subject: [PATCH] Fix Second ctrl+c should force quit the program #89 --- pkg/crawler/colly.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/crawler/colly.go b/pkg/crawler/colly.go index 59a3865..8c21a2d 100644 --- a/pkg/crawler/colly.go +++ b/pkg/crawler/colly.go @@ -281,15 +281,21 @@ func New(target string, txt string, html string, delayTime int, concurrency int, // Setup graceful exit chanC := make(chan os.Signal, 1) lettersNum := 23 + cCount := 0 signal.Notify(chanC, os.Interrupt) rand.Seed(time.Now().UnixNano()) go func() { for range chanC { + if cCount > 0 { + os.Exit(1) + } + if !plain { fmt.Fprint(os.Stdout, "\r") fmt.Println("CTRL+C pressed: Exiting") + cCount++ } c.AllowedDomains = []string{sliceUtils.RandSeq(lettersNum)}