File: src/session.zig:99-117 (reachable via cmdKillWindow,
cmd.zig:107-120, and break/join-pane rollback)
Severity: MEDIUM
Status: ✅ FIXED
New Server.unregisterWindowFds(win) removes every pty master of the window
from the poll set; it is called before Session.killWindow at all command
entry points (new-window rollback, both kill-window branches, and
join-pane’s source-window drop). Session stays decoupled from the loop.
Test: kill-window removes pane ptys from the poll set — bug #365
(two windows with fake ptys registered; after kill-window 1 only window 1’s
fd remains watched).
killWindow deinits panes — closing pty masters — but never removes them from
the poll set. Consequences:
handlePtyEvent lazily removes it (server.zig:668-671);loop.addFd dedup silently retargets the existing entry (loop.zig:39-51),
pointing stale udata at the new pane.Give Session/killWindow access to the loop (or return closed masters to the caller) so each pty master is removed before close, mirroring destroyPane’s pattern at server.zig:828-830.