Browse code

vendor: github.com/moby/term v0.0.0-20221205130635-1aeaba878587

term: remove interrupt handler on termios

On termios platforms, interrupt signals are not generated in raw mode
terminals as the ISIG setting is not enabled. Remove interrupt handler
as it does nothing for raw mode and prevents other uses of INT signal
with this library.

This code seems to go back all the way to moby/moby#214 where signal
handling was improved for monolithic docker repository. Raw mode -ISIG
got reintroduced in moby/moby@3f63b878076, but the INT handler was left
behind.

full diff: https://github.com/moby/term/compare/abb19827d345...1aeaba8785877a66f57739be9fccb6f5cfab429e

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

Sebastiaan van Stijn authored on 2022/12/05 22:46:33
Showing 4 changed files
... ...
@@ -67,7 +67,7 @@ require (
67 67
 	github.com/moby/sys/sequential v0.5.0
68 68
 	github.com/moby/sys/signal v0.7.0
69 69
 	github.com/moby/sys/symlink v0.2.0
70
-	github.com/moby/term v0.0.0-20221120202655-abb19827d345
70
+	github.com/moby/term v0.0.0-20221205130635-1aeaba878587
71 71
 	github.com/morikuni/aec v1.0.0
72 72
 	github.com/opencontainers/go-digest v1.0.0
73 73
 	github.com/opencontainers/image-spec v1.1.0-rc2.0.20221005185240-3a7f492d3f1b
... ...
@@ -1072,8 +1072,8 @@ github.com/moby/sys/symlink v0.2.0 h1:tk1rOM+Ljp0nFmfOIBtlV3rTDlWOwFRhjEeAhZB0nZ
1072 1072
 github.com/moby/sys/symlink v0.2.0/go.mod h1:7uZVF2dqJjG/NsClqul95CqKOBRQyYSNnJ6BMgR/gFs=
1073 1073
 github.com/moby/term v0.0.0-20200312100748-672ec06f55cd/go.mod h1:DdlQx2hp0Ss5/fLikoLlEeIYiATotOjgB//nb973jeo=
1074 1074
 github.com/moby/term v0.0.0-20200915141129-7f0af18e79f2/go.mod h1:TjQg8pa4iejrUrjiz0MCtMV38jdMNW4doKSiBrEvCQQ=
1075
-github.com/moby/term v0.0.0-20221120202655-abb19827d345 h1:J9c53/kxIH+2nTKBEfZYFMlhghtHpIHSXpm5VRGHSnU=
1076
-github.com/moby/term v0.0.0-20221120202655-abb19827d345/go.mod h1:15ce4BGCFxt7I5NQKT+HV0yEDxmf6fSysfEDiVo3zFM=
1075
+github.com/moby/term v0.0.0-20221205130635-1aeaba878587 h1:HfkjXDfhgVaN5rmueG8cL8KKeFNecRCXFhaJ2qZ5SKA=
1076
+github.com/moby/term v0.0.0-20221205130635-1aeaba878587/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y=
1077 1077
 github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
1078 1078
 github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
1079 1079
 github.com/modern-go/reflect2 v0.0.0-20180320133207-05fbef0ca5da/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
... ...
@@ -7,10 +7,8 @@ package term
7 7
 
8 8
 import (
9 9
 	"errors"
10
-	"fmt"
11 10
 	"io"
12 11
 	"os"
13
-	"os/signal"
14 12
 
15 13
 	"golang.org/x/sys/unix"
16 14
 )
... ...
@@ -80,7 +78,6 @@ func DisableEcho(fd uintptr, state *State) error {
80 80
 	if err := tcset(fd, &newState); err != nil {
81 81
 		return err
82 82
 	}
83
-	handleInterrupt(fd, state)
84 83
 	return nil
85 84
 }
86 85
 
... ...
@@ -92,7 +89,6 @@ func SetRawTerminal(fd uintptr) (*State, error) {
92 92
 	if err != nil {
93 93
 		return nil, err
94 94
 	}
95
-	handleInterrupt(fd, oldState)
96 95
 	return oldState, err
97 96
 }
98 97
 
... ...
@@ -102,18 +98,3 @@ func SetRawTerminal(fd uintptr) (*State, error) {
102 102
 func SetRawTerminalOutput(fd uintptr) (*State, error) {
103 103
 	return nil, nil
104 104
 }
105
-
106
-func handleInterrupt(fd uintptr, state *State) {
107
-	sigchan := make(chan os.Signal, 1)
108
-	signal.Notify(sigchan, os.Interrupt)
109
-	go func() {
110
-		for range sigchan {
111
-			// quit cleanly and the new terminal item is on a new line
112
-			fmt.Println()
113
-			signal.Stop(sigchan)
114
-			close(sigchan)
115
-			RestoreTerminal(fd, state)
116
-			os.Exit(1)
117
-		}
118
-	}()
119
-}
... ...
@@ -819,7 +819,7 @@ github.com/moby/sys/signal
819 819
 # github.com/moby/sys/symlink v0.2.0
820 820
 ## explicit; go 1.16
821 821
 github.com/moby/sys/symlink
822
-# github.com/moby/term v0.0.0-20221120202655-abb19827d345
822
+# github.com/moby/term v0.0.0-20221205130635-1aeaba878587
823 823
 ## explicit; go 1.18
824 824
 github.com/moby/term
825 825
 github.com/moby/term/windows