summary refs log tree commit diff
diff options
context:
space:
mode:
authorLain Iwakura <lain@lainmail.xyz>2026-01-04 05:11:31 +0300
committerLain Iwakura <lain@lainmail.xyz>2026-01-04 05:11:31 +0300
commit5f37319aeb3084b890cfd3b21f2dc33034122289 (patch)
tree312dd0b9129b2e6897732fd473d5f43070ab11d2
parentfix(deploy.sh): systemgoi (diff)
downloadtorus-5f37319aeb3084b890cfd3b21f2dc33034122289.tar.gz
torus-5f37319aeb3084b890cfd3b21f2dc33034122289.zip
feat(client:exit): byee :33 HEAD master
-rw-r--r--client.c10
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 },