diff options
| author | gbc dev <gbc@localhost> | 2026-07-15 01:42:34 +0200 |
|---|---|---|
| committer | gbc dev <gbc@localhost> | 2026-07-15 01:42:34 +0200 |
| commit | 2d39cb0b3ff9851e9872b3eb1f1324bde6910a1c (patch) | |
| tree | 6094106082817288518b2b98e62d4073a10d3776 /src/control.c | |
| parent | tools: live debug HUD (gbhud.py) + 'gbctl hud' (diff) | |
| download | sl0pboy-2d39cb0b3ff9851e9872b3eb1f1324bde6910a1c.tar.gz sl0pboy-2d39cb0b3ff9851e9872b3eb1f1324bde6910a1c.tar.xz sl0pboy-2d39cb0b3ff9851e9872b3eb1f1324bde6910a1c.zip | |
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.
Diffstat (limited to 'src/control.c')
| -rw-r--r-- | src/control.c | 5 |
1 files changed, 5 insertions, 0 deletions
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 <errno.h> #include <unistd.h> #include <fcntl.h> +#include <signal.h> #include <sys/socket.h> #include <sys/un.h> @@ -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); |
