szn

Bug 403 — sendResponse busy-spins forever when an O_NONBLOCK display fd hits EAGAIN — one stalled client freezes the whole server (#322 regression)

403. sendResponse busy-spins forever when an O_NONBLOCK display fd hits EAGAIN — one stalled client freezes the whole server (#322 regression)

Severity: HIGH Status: ✅ RESOLVED

The #322 fix replaced blocking writes with a retry loop that treats AGAIN as retry-later inside the loop:

const n = std.c.write(fd, hdr_remaining.ptr, hdr_remaining.len);
if (n < 0) {
    const err = std.c.errno(n);
    if (err == .INTR or err == .AGAIN) continue;   // spin, never yield

Every display socket is O_NONBLOCK (server.zig:2392). A client that received a command response while stopped (SIGSTOP), hung, or already detached-but-still-registered (:2530 removes it from display_clients only — the fd stays in client_fds) never drains the socket buffer: sendResponse spins in a tight loop inside handleClient, the single-threaded server never returns to poll, and every pane, client, and PTY wedges.

Fix: route replies through the POLLOUT queue like display frames, or bound the AGAIN retries and give up + disconnect. Never busy-wait inside the event loop.