From fac51df2abec19e57932e0fbe4492d372d7daac2 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 4 Nov 2026 21:23:04 -0300 Subject: pty/run: a run waiting for a new terminal's first prompt is the only line typed there: the Term's greeting ls is dropped when the run's line goes (pty.zig noteMarks), as on the window (resized, so it greets) both were typed at that prompt and ls's C, read with true's in one chunk, left the run waiting for ever (4 runs of 6); the window's process sessions run on a 160x50 pty (Child.Pty's cols and rows), as a test window follows its terminal's size and the 80x24 one made the canary's Newcol find no room; terminals' pty/run case and the canary run on both backends (10 of 10 each on the window), their next-tests Open bullets gone; a pty.zig unit test that fails without the fix (truels) Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge --- test/process.zig | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'test/process.zig') diff --git a/test/process.zig b/test/process.zig index bba795de..ba6a84a8 100644 --- a/test/process.zig +++ b/test/process.zig @@ -621,8 +621,9 @@ pub const Detached = struct { .root = dir, .env = env[0..n], .unset = if (gui) &.{ "WAYLAND_DISPLAY", "DISPLAY" } else &.{}, - // A window runs on a terminal of its own, as one started from a shell. - .pty = if (gui) .{ .log = try std.fmt.bufPrintSentinel(&bufs[3], "{s}/{s}.pty", .{ dir, name }, 0) } else null, + // A window runs on a terminal of its own, as one started from a + // shell, the grid's size: a test window follows its terminal's. + .pty = if (gui) .{ .log = try std.fmt.bufPrintSentinel(&bufs[3], "{s}/{s}.pty", .{ dir, name }, 0), .cols = 160, .rows = 50 } else null, .err_log = try std.fmt.bufPrintSentinel(&bufs[4], "{s}/{s}.stderr", .{ dir, name }, 0), }); errdefer d.child.deinit(); @@ -793,6 +794,9 @@ pub const Child = struct { log: [:0]const u8, /// Made its controlling terminal; else a pty that is no one's. ctty: bool = true, + /// Its size: a test window follows its terminal's (gui.zig's StdinFeed). + cols: u16 = 80, + rows: u16 = 24, }; pub const Options = struct { @@ -806,7 +810,7 @@ pub const Child = struct { unset: []const [:0]const u8 = &.{}, /// Its stdin, written whole and closed; null: /dev/null. stdin: ?[]const u8 = null, - /// Started in a 24x80 pty, its stdin and stdout. + /// Started in a pty (80x24 unless it says), its stdin and stdout. pty: ?Pty = null, /// Its stderr to this file, not a pipe: a long session's, which /// nobody reads while it runs and which must never fill. `said` @@ -837,8 +841,8 @@ pub const Child = struct { @memcpy(c.err_path[0..path.len], path); c.err_path_len = path.len; } - if (opts.pty != null) { - var ws: std.posix.winsize = .{ .row = 24, .col = 80, .xpixel = 0, .ypixel = 0 }; + if (opts.pty) |p| { + var ws: std.posix.winsize = .{ .row = p.rows, .col = p.cols, .xpixel = 0, .ypixel = 0 }; if (openpty(&c.master, &c.slave, null, null, &ws) != 0) return error.NoPty; for ([_]c_int{ c.master, c.slave }) |fd| _ = libc.fcntl(fd, libc.F.SETFD, @as(c_int, 1)); // FD_CLOEXEC } -- cgit v1.3