Skip to content

Commit

Permalink
Add program exit with ctrl + c and minor error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
IsThisEvenCode committed Jun 12, 2024
1 parent 02abb15 commit 8643e4e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pkg/modgearman/gearman_top.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,14 @@ func runInteractiveMode(args *Args, hostList []string, connectionMap map[string]
for {
select {
case ev := <-eventQueue:
if ev.Type == termbox.EventKey && (ev.Key == termbox.KeyEsc || ev.Ch == 'q' || ev.Ch == 'Q') {
if ev.Type == termbox.EventKey && (ev.Key == termbox.KeyEsc || ev.Ch == 'q' || ev.Ch == 'Q' || ev.Key == termbox.KeyCtrlC) {
// Close all active connections
for key := range connectionMap {
if connectionMap[key] != nil {
connectionMap[key].Close()
err := connectionMap[key].Close()
if err != nil {
fmt.Printf("Error closing connection %v\n", err)

Check failure on line 129 in pkg/modgearman/gearman_top.go

View workflow job for this annotation

GitHub Actions / test

use of `fmt.Printf` forbidden by pattern `^(fmt\.Print(|f|ln)|print|println)$` (forbidigo)
}
}
}
return
Expand Down

0 comments on commit 8643e4e

Please sign in to comment.