catch sigint and restore term

This commit is contained in:
Ted Unangst 2019-11-10 20:20:56 -05:00
parent 874836ba74
commit cc613e8962
1 changed files with 8 additions and 0 deletions

View File

@ -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)