Skip to content

Commit

Permalink
Merge pull request #31 from enool/remove-int-handler
Browse files Browse the repository at this point in the history
term: remove interrupt handler on termios
  • Loading branch information
thaJeztah authored Nov 28, 2022
2 parents abb1982 + 94b314a commit c43b287
Showing 1 changed file with 0 additions and 19 deletions.
19 changes: 0 additions & 19 deletions term.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ package term

import (
"errors"
"fmt"
"io"
"os"
"os/signal"

"golang.org/x/sys/unix"
)
Expand Down Expand Up @@ -80,7 +78,6 @@ func DisableEcho(fd uintptr, state *State) error {
if err := tcset(fd, &newState); err != nil {
return err
}
handleInterrupt(fd, state)
return nil
}

Expand All @@ -92,7 +89,6 @@ func SetRawTerminal(fd uintptr) (*State, error) {
if err != nil {
return nil, err
}
handleInterrupt(fd, oldState)
return oldState, err
}

Expand All @@ -102,18 +98,3 @@ func SetRawTerminal(fd uintptr) (*State, error) {
func SetRawTerminalOutput(fd uintptr) (*State, error) {
return nil, nil
}

func handleInterrupt(fd uintptr, state *State) {
sigchan := make(chan os.Signal, 1)
signal.Notify(sigchan, os.Interrupt)
go func() {
for range sigchan {
// quit cleanly and the new terminal item is on a new line
fmt.Println()
signal.Stop(sigchan)
close(sigchan)
RestoreTerminal(fd, state)
os.Exit(1)
}
}()
}

0 comments on commit c43b287

Please sign in to comment.