Fix frozen client on ctrl+q: send bye instead of half-closing

Dropping the client's channel sender never closed the socket (the
server's reader thread keeps the connection open), so the client froze
waiting for frames. The server now sends a bye message; the client
exits cleanly on it and its socket close lets the server clean up.
Messages from already-disconnected clients are ignored. Verified
end-to-end with the real client in a PTY (exits 0, daemon survives).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-15 19:08:04 +02:00
parent db18c42481
commit 373294e2b9
4 changed files with 23 additions and 5 deletions

View File

@@ -148,13 +148,15 @@ def main():
disp2.recv_until("frame")
disp2.send(key_event(ch="q", modifiers="CONTROL"))
try:
got_bye = False
deadline = time.time() + 3
while time.time() < deadline:
disp2.recv()
disconnected = False
if disp2.recv().get("type") == "bye":
got_bye = True
break
except (EOFError, TimeoutError, OSError):
disconnected = True
check("ctrl+q från klient kopplar ner klienten", disconnected)
pass # EOF duger också som nedkoppling
check("ctrl+q från klient ger bye till klienten", got_bye)
frame = disp.recv_until("frame")
check("daemonen överlever klientens exit", frame.get("width", 0) > 0)