diff options
| author | Lain Iwakura <lain@lainmail.xyz> | 2026-01-04 05:11:31 +0300 |
|---|---|---|
| committer | Lain Iwakura <lain@lainmail.xyz> | 2026-01-04 05:11:31 +0300 |
| commit | 5f37319aeb3084b890cfd3b21f2dc33034122289 (patch) | |
| tree | 312dd0b9129b2e6897732fd473d5f43070ab11d2 | |
| parent | fix(deploy.sh): systemgoi (diff) | |
| download | torus-master.tar.gz torus-master.zip | |
| -rw-r--r-- | client.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/client.c b/client.c index e88a714..1dc572f 100644 --- a/client.c +++ b/client.c @@ -28,6 +28,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <signal.h> #include <sys/socket.h> #include <sys/un.h> #include <sysexits.h> @@ -135,6 +136,13 @@ static uint8_t cellX; static uint8_t cellY; static struct Tile tile; +static void handleSigint(int sig) { + (void)sig; + endwin(); + fprintf(stderr, "bye :33\n"); + exit(EX_OK); +} + static void serverTile(void) { ssize_t size = recv(client, &tile, sizeof(tile), 0); if (size < 0) err(EX_IOERR, "recv"); @@ -738,6 +746,8 @@ int main(int argc, char *argv[]) { if (error) err(EX_OSERR, "pledge"); #endif + signal(SIGINT, handleSigint); + struct pollfd fds[2] = { { .fd = STDIN_FILENO, .events = POLLIN }, { .fd = client, .events = POLLIN }, |