szn

Bug 68 — Potential double-close of PTY fds from conflicting deinit paths

68. Potential double-close of PTY fds from conflicting deinit paths

File: src/session.zig:49–57 Severity: CRITICAL Status: ✅ FIXED — both Session.deinit and killWindow now call Pane.deinit() (single cleanup path) instead of inlining pty.deinit().

pub fn deinit(self: *Session, allocator: std.mem.Allocator) void {
    for (self.windows.items) |win| {
        for (win.panes.items) |p| {
            if (p.pty) |*pty| pty.deinit();  // manual PTY cleanup
        }
    }
    self.arena.deinit();  // no Pane.deinit() or Window.deinit() called
}

Session.deinit manually deinits PTY fds but never calls Pane.deinit() or Window.deinit(). If Pane.deinit() is ever added (which also calls pty.deinit()), the PTY fd gets closed twice — potentially closing an unrelated fd reused by another subsystem. Should ensure only one code path handles PTY cleanup.