diff --git a/docker/docker.go b/docker/docker.go index 686cd2181afa87570e8f8c31d9cc938fc524787b..092e9ba2d0cac864a1726bdf5615fe824f4d3fd1 100644 --- a/docker/docker.go +++ b/docker/docker.go @@ -8,6 +8,7 @@ import ( "io" "log" "os" + "os/signal" ) func main() { @@ -53,6 +54,15 @@ func runCommand(args []string) error { return err } defer term.Restore(0, oldState) + c := make(chan os.Signal, 1) + signal.Notify(c, os.Interrupt) + go func() { + for _ = range c { + term.Restore(0, oldState) + log.Printf("\nSIGINT received\n") + os.Exit(0) + } + }() } // FIXME: we want to use unix sockets here, but net.UnixConn doesn't expose // CloseWrite(), which we need to cleanly signal that stdin is closed without diff --git a/term/termios_linux.go b/term/termios_linux.go index ef2c84c7e829cd553769cf4be51b96addeba3afe..5275ba87fb09c93119d1bc5f08f02fcab9543808 100644 --- a/term/termios_linux.go +++ b/term/termios_linux.go @@ -15,7 +15,7 @@ void MakeRaw(int fd) { ioctl(fd, TCGETS, &t); t.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | ICRNL | IXON); - t.c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN); + t.c_lflag &= ~(ECHO | ECHONL | ICANON | IEXTEN); t.c_cflag &= ~(CSIZE | PARENB); t.c_cflag |= CS8;