From 6490c179e7f789a9efb876fa0bdfc195dc374dc5 Mon Sep 17 00:00:00 2001 From: Lizzy Fleckenstein Date: Wed, 19 Jun 2024 18:31:01 +0200 Subject: handle signals Signed-off-by: Lizzy Fleckenstein --- src/client.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/client.c') diff --git a/src/client.c b/src/client.c index 0dabbbf..3bf3649 100644 --- a/src/client.c +++ b/src/client.c @@ -9,6 +9,7 @@ #include "ser.h" #include "net.h" #include "ticker.h" +#include "sig.h" typedef struct { peer conn; @@ -59,6 +60,8 @@ bool handle_pkt(client *c, str pkt) int main() { + signal_setup(); + client c = {0}; c.name = str_clone(S("kitten")); @@ -94,11 +97,14 @@ int main() if (poll(fds, 2, ticker_timeout(&t)) < 0) { switch (errno) { - case EINTR: continue; + case EINTR: break; default: perror("poll"); continue; } } + if (signal_stop) + client_exit(&c, EXIT_SUCCESS); + if (fds[0].revents) { // this is cursed // maybe dont do this idk -- cgit v1.2.3