szn

Bug 374 — Detach notification dropped on EAGAIN

374. One of two remaining raw-write paths on non-blocking fds

File: src/server/server.zig:1009-1017 (also sendRequestCellSize at server.zig:2464-2470) Severity: MEDIUM Status: ✅ FIXED

Fix (applied)

The detach notification now goes through queueToClient (POLLOUT-queued, EAGAIN-safe) instead of a raw blocking-style retry loop that broke out on EAGAIN and silently truncated/dropped the 6-byte packet. The twin site (sendRequestCellSize) already had EAGAIN/partial fallback queueing — verified while here.

No dedicated unit test: the interactive detach path needs a live display client; the change reuses the queueToClient machinery covered by existing clipboard/command-response tests, all green.

Problem

while (remaining.len > 0) {
    const written_bytes = c.write(cfd, remaining.ptr, remaining.len);
    if (written_bytes < 0) { if (...== .INTR) continue; break; }   // EAGAIN → drop

Display sockets are flipped O_NONBLOCK by registerDisplayClient; when the peer isn’t reading, the 6-byte detach packet is truncated or lost entirely and the client is never told to exit. Everything else routes through the POLLOUT queue (queueToClient).

Fix (proposed)

Use queueToClient for the detach reply (and audit sendRequestCellSize’s raw write — it drops EPIPE/EINTR too).