setupInteractiveTerminal configures the terminal for interactive PTY usage: raw mode for escape sequences, initial size inheritance, and resize handling.
(ptmx *os.File)
| 25 | // setupInteractiveTerminal configures the terminal for interactive PTY usage: |
| 26 | // raw mode for escape sequences, initial size inheritance, and resize handling. |
| 27 | func setupInteractiveTerminal(ptmx *os.File) func() { |
| 28 | stdinFd := int(os.Stdin.Fd()) |
| 29 | |
| 30 | if !term.IsTerminal(stdinFd) { |
| 31 | return func() {} |
| 32 | } |
| 33 | |
| 34 | _ = pty.InheritSize(os.Stdin, ptmx) |
| 35 | |
| 36 | ch := make(chan os.Signal, 1) |
| 37 | signal.Notify(ch, syscall.SIGWINCH) |
| 38 | |
| 39 | go func() { |
| 40 | for range ch { |
| 41 | _ = pty.InheritSize(os.Stdin, ptmx) |
| 42 | } |
| 43 | }() |
| 44 | |
| 45 | oldState, err := term.MakeRaw(stdinFd) |
| 46 | if err != nil { |
| 47 | signal.Stop(ch) |
| 48 | |
| 49 | return func() {} |
| 50 | } |
| 51 | |
| 52 | return func() { |
| 53 | term.Restore(stdinFd, oldState) //nolint:errcheck |
| 54 | signal.Stop(ch) |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | func (d *Docker) HasuraWrapper( |
| 59 | ctx context.Context, |