From 2f3fd9b624591666f9a1f86db75e93f5f52f944c Mon Sep 17 00:00:00 2001 From: tomholford Date: Wed, 18 Feb 2026 13:38:20 -0800 Subject: [PATCH] term: clamp zero window size from Docker PTY MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When Docker allocates a PTY (tty: true + stdin_open: true) but nobody is attached, TIOCGWINSZ succeeds but reports 0x0. This causes a decrement-underflow crash in drum when it receives %blew [0 0]. Clamp to 80x24 defaults when ioctl returns zero dimensions, matching the existing fallback when ioctl fails entirely. Unlike the prior attempt (#959), this does not change the initial row_l from 0 — that value serves as a sentinel throughout term.c to skip cursor positioning during early boot (checked by hija/loja and the spinner). Changing it to 24 caused blank lines in terminal output on macOS. Resolves #159. --- pkg/vere/io/term.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/vere/io/term.c b/pkg/vere/io/term.c index ca36408854..6ac0b119d3 100644 --- a/pkg/vere/io/term.c +++ b/pkg/vere/io/term.c @@ -1038,6 +1038,11 @@ u3_term_get_blew(c3_l tid_l) if ( (c3n == u3_Host.ops_u.tem) && uty_u && (c3y == uty_u->wsz_f(uty_u, &col_l, &row_l)) ) { + // clamp to defaults if ioctl returns zero + // (e.g. Docker PTY with no attached reader) + // + if ( 0 == col_l ) { col_l = 80; } + if ( 0 == row_l ) { row_l = 24; } uty_u->tat_u.siz.col_l = col_l; uty_u->tat_u.siz.row_l = row_l; }