about summary refs log tree commit diff
path: root/htping.go
diff options
context:
space:
mode:
Diffstat (limited to 'htping.go')
-rw-r--r--htping.go5
1 files changed, 3 insertions, 2 deletions
diff --git a/htping.go b/htping.go
index b480237..cfeb236 100644
--- a/htping.go
+++ b/htping.go
@@ -333,7 +333,8 @@ func main() {
 		network = "tcp6"
 	}
 
-	ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt)
+	ctx, cancel := context.WithCancel(context.Background())
+	ctx, stop := signal.NotifyContext(ctx, os.Interrupt)
 	defer stop()
 
 	var wg sync.WaitGroup
@@ -434,7 +435,7 @@ func main() {
 				count++
 				for {
 					if *maxCount > 0 && count > *maxCount {
-						break
+						cancel()
 					}
 					select {
 					case <-ctx.Done():