MCPcopy Create free account
hub / github.com/containerd/nerdctl / HandleConsoleResize

Function HandleConsoleResize

pkg/consoleutil/consoleutil_unix.go:34–58  ·  view source on GitHub ↗

HandleConsoleResize resizes the console. From https://github.com/containerd/containerd/blob/v1.7.0-rc.2/cmd/ctr/commands/tasks/tasks_unix.go#L43-L68

(ctx context.Context, task resizer, con console.Console)

Source from the content-addressed store, hash-verified

32// HandleConsoleResize resizes the console.
33// From https://github.com/containerd/containerd/blob/v1.7.0-rc.2/cmd/ctr/commands/tasks/tasks_unix.go#L43-L68
34func HandleConsoleResize(ctx context.Context, task resizer, con console.Console) error {
35 // do an initial resize of the console
36 size, err := con.Size()
37 if err != nil {
38 return err
39 }
40 if err := task.Resize(ctx, uint32(size.Width), uint32(size.Height)); err != nil {
41 log.G(ctx).WithError(err).Error("resize pty")
42 }
43 s := make(chan os.Signal, 16)
44 signal.Notify(s, unix.SIGWINCH)
45 go func() {
46 for range s {
47 size, err := con.Size()
48 if err != nil {
49 log.G(ctx).WithError(err).Error("get pty size")
50 continue
51 }
52 if err := task.Resize(ctx, uint32(size.Width), uint32(size.Height)); err != nil {
53 log.G(ctx).WithError(err).Error("resize pty")
54 }
55 }
56 }()
57 return nil
58}

Callers

nothing calls this directly

Calls 3

SizeMethod · 0.80
ResizeMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…