MCPcopy Create free account
hub / github.com/nhost/nhost / setupInteractiveTerminal

Function setupInteractiveTerminal

cli/dockercompose/docker.go:27–56  ·  view source on GitHub ↗

setupInteractiveTerminal configures the terminal for interactive PTY usage: raw mode for escape sequences, initial size inheritance, and resize handling.

(ptmx *os.File)

Source from the content-addressed store, hash-verified

25// setupInteractiveTerminal configures the terminal for interactive PTY usage:
26// raw mode for escape sequences, initial size inheritance, and resize handling.
27func 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
58func (d *Docker) HasuraWrapper(
59 ctx context.Context,

Callers 1

HasuraWrapperMethod · 0.85

Calls 1

StopMethod · 0.65

Tested by

no test coverage detected