From cc613e8962eacf252d4115d9cc8fdb057d79f5ce Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Sun, 10 Nov 2019 20:20:56 -0500 Subject: [PATCH] catch sigint and restore term --- admin.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/admin.go b/admin.go index bcfb7a0..3c391b0 100644 --- a/admin.go +++ b/admin.go @@ -25,6 +25,7 @@ import ( "io/ioutil" "log" "os" + "os/signal" ) func adminscreen() { @@ -98,6 +99,13 @@ func adminscreen() { C.tcsetattr(1, C.TCSAFLUSH, savedtio) } defer restore() + go func() { + sig := make(chan os.Signal) + signal.Notify(sig, os.Interrupt) + <-sig + restore() + os.Exit(0) + }() init := func() { tio := new(C.struct_termios)