From 2d39cb0b3ff9851e9872b3eb1f1324bde6910a1c Mon Sep 17 00:00:00 2001 From: gbc dev Date: Wed, 15 Jul 2026 01:42:34 +0200 Subject: fix(control): ignore SIGPIPE so a vanishing client can't kill the emulator A client that connects and closes before reading (e.g. the HUD's liveness probe) made the greeting write() raise SIGPIPE, terminating the whole emulator - this was behind much of the 'it keeps dying' this session. Also: gbhud now re-resolves the live instance from the registry on every reconnect (skipping stale sockets by test-connecting), so the HUD follows respawns, and its box rendering is ANSI-width-correct. --- src/control.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/control.c') diff --git a/src/control.c b/src/control.c index 322646b..5cea4e0 100644 --- a/src/control.c +++ b/src/control.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -508,6 +509,10 @@ static void service_client(GB *gb, int i) { // --------------------------------------------------------------------------- void control_open(const char *path) { + // A client can connect and vanish before we finish writing (e.g. a liveness + // probe that connects and closes without reading the greeting). Ignore + // SIGPIPE so those writes fail with EPIPE instead of killing the emulator. + signal(SIGPIPE, SIG_IGN); for (int i = 0; i < MAX_CLIENTS; i++) clients[i].fd = -1; listen_fd = socket(AF_UNIX, SOCK_STREAM, 0); -- cgit v1.3.1-sl0p