Prechádzať zdrojové kódy

Disable signal catching and enable real posix raw mode

Guillaume J. Charmes 12 rokov pred
rodič
commit
3f63b87807
2 zmenil súbory, kde vykonal 11 pridanie a 1 odobranie
  1. 9 0
      docker/docker.go
  2. 2 1
      term/termios_linux.go

+ 9 - 0
docker/docker.go

@@ -56,6 +56,15 @@ func daemon() error {
 }
 
 func runCommand(args []string) error {
+	var oldState *term.State
+	var err error
+	if term.IsTerminal(int(os.Stdin.Fd())) && os.Getenv("NORAW") == "" {
+		oldState, err = term.MakeRaw(int(os.Stdin.Fd()))
+		if err != nil {
+			return err
+		}
+		defer term.Restore(int(os.Stdin.Fd()), oldState)
+	}
 	// 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
 	// closing the connection.

+ 2 - 1
term/termios_linux.go

@@ -15,7 +15,8 @@ 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 | IEXTEN);
+  t.c_oflag &= ~OPOST;
+  t.c_lflag &= ~(ECHO | ECHONL | ICANON | IEXTEN | ISIG);
   t.c_cflag &= ~(CSIZE | PARENB);
   t.c_cflag |= CS8;