Parcourir la source

Simplification in the goroutine that restore the terminal state on SIGINT

Louis Opter il y a 12 ans
Parent
commit
b306a60738
1 fichiers modifiés avec 3 ajouts et 5 suppressions
  1. 3 5
      docker/docker.go

+ 3 - 5
docker/docker.go

@@ -65,11 +65,9 @@ func setRawTerminal() (*term.State, error) {
 	c := make(chan os.Signal, 1)
 	signal.Notify(c, os.Interrupt)
 	go func() {
-		for _ = range c {
-			term.Restore(int(os.Stdin.Fd()), oldState)
-			log.Printf("\nSIGINT received\n")
-			os.Exit(0)
-		}
+		_ = <-c
+		term.Restore(int(os.Stdin.Fd()), oldState)
+		os.Exit(0)
 	}()
 	return oldState, err
 }