MCPcopy Index your code
hub / github.com/docker/cli / MonitorTtySize

Function MonitorTtySize

cli/command/container/tty.go:80–106  ·  view source on GitHub ↗

MonitorTtySize updates the container tty size when the terminal tty changes size

(ctx context.Context, cli command.Cli, id string, isExec bool)

Source from the content-addressed store, hash-verified

78
79// MonitorTtySize updates the container tty size when the terminal tty changes size
80func MonitorTtySize(ctx context.Context, cli command.Cli, id string, isExec bool) error {
81 initTtySize(ctx, cli, id, isExec, resizeTty)
82 if runtime.GOOS == "windows" {
83 go func() {
84 prevH, prevW := cli.Out().GetTtySize()
85 for {
86 time.Sleep(time.Millisecond * 250)
87 h, w := cli.Out().GetTtySize()
88
89 if prevW != w || prevH != h {
90 _ = resizeTty(ctx, cli, id, isExec)
91 }
92 prevH = h
93 prevW = w
94 }
95 }()
96 } else {
97 sigchan := make(chan os.Signal, 1)
98 gosignal.Notify(sigchan, signal.SIGWINCH)
99 go func() {
100 for range sigchan {
101 _ = resizeTty(ctx, cli, id, isExec)
102 }
103 }()
104 }
105 return nil
106}

Callers 4

RunStartFunction · 0.85
resizeTTYFunction · 0.85
interactiveExecFunction · 0.85
runContainerFunction · 0.85

Calls 4

initTtySizeFunction · 0.85
resizeTtyFunction · 0.85
GetTtySizeMethod · 0.80
OutMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…