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

Function initTtySize

cli/command/container/tty.go:58–77  ·  view source on GitHub ↗

initTtySize is to init the TTYs size to the same as the window, if there is an error, it will retry 10 times.

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

Source from the content-addressed store, hash-verified

56
57// initTtySize is to init the TTYs size to the same as the window, if there is an error, it will retry 10 times.
58func initTtySize(ctx context.Context, cli command.Cli, id string, isExec bool, resizeTtyFunc func(ctx context.Context, cli command.Cli, id string, isExec bool) error) {
59 rTTYfunc := resizeTtyFunc
60 if rTTYfunc == nil {
61 rTTYfunc = resizeTty
62 }
63 if err := rTTYfunc(ctx, cli, id, isExec); err != nil {
64 go func() {
65 var err error
66 for retry := range 10 {
67 time.Sleep(time.Duration(retry+1) * 10 * time.Millisecond)
68 if err = rTTYfunc(ctx, cli, id, isExec); err == nil {
69 break
70 }
71 }
72 if err != nil {
73 _, _ = fmt.Fprintln(cli.Err(), "failed to resize tty, using default size")
74 }
75 }()
76 }
77}
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 {

Callers 2

MonitorTtySizeFunction · 0.85
TestInitTtySizeErrorsFunction · 0.85

Calls 1

ErrMethod · 0.65

Tested by 1

TestInitTtySizeErrorsFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…