repos / zmx

session persistence for terminal processes
git clone https://github.com/neurosnap/zmx.git

commit
b0a88af
parent
0fdf98f
author
Eric Bower
date
2025-12-15 20:10:24 -0500 EST
fix: send SIGWINCH to PTY on re-attach

TIOCSWINSZ alone doesn't notify the shell when terminal size is set.
Now we explicitly signal the foreground process group after setting
the window size, fixing display issues on re-attach.
1 files changed,  +6, -0
M src/main.zig
+6, -0
 1@@ -752,6 +752,12 @@ fn daemonLoop(daemon: *Daemon, server_sock_fd: i32, pty_fd: i32) !void {
 2                                 };
 3                                 _ = c.ioctl(pty_fd, c.TIOCSWINSZ, &ws);
 4                                 try term.resize(daemon.alloc, resize.cols, resize.rows);
 5+
 6+                                // Force SIGWINCH to PTY foreground process group on re-attach
 7+                                var pgrp: posix.pid_t = 0;
 8+                                if (c.ioctl(pty_fd, c.TIOCGPGRP, &pgrp) == 0 and pgrp > 0) {
 9+                                    posix.kill(-pgrp, posix.SIG.WINCH) catch {};
10+                                }
11                                 std.log.debug("init resize rows={d} cols={d}", .{ resize.rows, resize.cols });
12 
13                                 // Only send terminal state if there's been PTY output (skip on first attach)