MonitorTtySize updates the container tty size when the terminal tty changes size
(ctx context.Context, cli command.Cli, id string, isExec bool)
| 78 | |
| 79 | // MonitorTtySize updates the container tty size when the terminal tty changes size |
| 80 | func 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 | } |
no test coverage detected
searching dependent graphs…