From 1c23cf1725df30facc07a361f321457ac5638be2 Mon Sep 17 00:00:00 2001 From: Daniel Canter Date: Fri, 11 Mar 2022 18:32:43 -0800 Subject: [PATCH] Respect console size for hostprocess containers Previously the values in the spec weren't being used. This change additionally changes the defaults to an 80 width and 25 height to match what cexecsvc/hcs sets. Signed-off-by: Daniel Canter --- internal/jobcontainers/jobcontainer.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/internal/jobcontainers/jobcontainer.go b/internal/jobcontainers/jobcontainer.go index b77ba9b1db..b9cb630fab 100644 --- a/internal/jobcontainers/jobcontainer.go +++ b/internal/jobcontainers/jobcontainer.go @@ -250,7 +250,20 @@ func (c *JobContainer) CreateProcess(ctx context.Context, config interface{}) (_ var cpty *conpty.Pty if conf.EmulateConsole { - cpty, err = conpty.Create(80, 20, 0) + height := int16(25) + width := int16(80) + // ConsoleSize is just an empty slice that needs to be filled. First element is expected to + // be height, second is width. + if len(conf.ConsoleSize) == 2 { + if conf.ConsoleSize[0] != 0 { + height = int16(conf.ConsoleSize[0]) + } + if conf.ConsoleSize[1] != 0 { + width = int16(conf.ConsoleSize[1]) + } + } + + cpty, err = conpty.Create(width, height, 0) if err != nil { return nil, err }