Skip to content

Commit 94b314a

Browse files
committed
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. Signed-off-by: Sami Loone <[email protected]>
1 parent 39b0c02 commit 94b314a

File tree

1 file changed

+0
-19
lines changed

1 file changed

+0
-19
lines changed

term.go

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@ package term
66

77
import (
88
"errors"
9-
"fmt"
109
"io"
1110
"os"
12-
"os/signal"
1311

1412
"golang.org/x/sys/unix"
1513
)
@@ -81,7 +79,6 @@ func DisableEcho(fd uintptr, state *State) error {
8179
if err := tcset(fd, &newState); err != nil {
8280
return err
8381
}
84-
handleInterrupt(fd, state)
8582
return nil
8683
}
8784

@@ -93,7 +90,6 @@ func SetRawTerminal(fd uintptr) (*State, error) {
9390
if err != nil {
9491
return nil, err
9592
}
96-
handleInterrupt(fd, oldState)
9793
return oldState, err
9894
}
9995

@@ -103,18 +99,3 @@ func SetRawTerminal(fd uintptr) (*State, error) {
10399
func SetRawTerminalOutput(fd uintptr) (*State, error) {
104100
return nil, nil
105101
}
106-
107-
func handleInterrupt(fd uintptr, state *State) {
108-
sigchan := make(chan os.Signal, 1)
109-
signal.Notify(sigchan, os.Interrupt)
110-
go func() {
111-
for range sigchan {
112-
// quit cleanly and the new terminal item is on a new line
113-
fmt.Println()
114-
signal.Stop(sigchan)
115-
close(sigchan)
116-
RestoreTerminal(fd, state)
117-
os.Exit(1)
118-
}
119-
}()
120-
}

0 commit comments

Comments
 (0)