diff options
| -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 }, |