Skip to content

Commit 59cd548

Browse files
committed
handle ctrl+\ in addition to ctrl+c
Signed-off-by: John Clark <[email protected]>
1 parent d0c3e88 commit 59cd548

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

monitor.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"fmt"
77
"os"
88
"os/signal"
9+
"syscall"
910
"time"
1011

1112
"github.com/mattn/go-tty"
@@ -42,13 +43,18 @@ func Monitor(port string, baud int) error {
4243
defer tty.Close()
4344

4445
sig := make(chan os.Signal, 1)
45-
signal.Notify(sig, os.Interrupt)
46+
signal.Notify(sig, os.Interrupt, syscall.SIGQUIT)
4647
defer signal.Stop(sig)
4748

4849
go func() {
4950
for {
50-
<-sig
51-
p.Write([]byte{0x1b, 0x03}) // send ctrl+c to tty
51+
sig := <-sig
52+
switch sig {
53+
case os.Interrupt:
54+
p.Write([]byte{0x1b, 0x03}) // send ctrl+c to tty
55+
case syscall.SIGQUIT:
56+
p.Write([]byte{0x1b, 0x1c}) // send ctrl+\ to tty
57+
}
5258
}
5359
}()
5460

0 commit comments

Comments
 (0)