summaryrefslogtreecommitdiff
path: root/src/client.c
diff options
context:
space:
mode:
authorLizzy Fleckenstein <lizzy@vlhl.dev>2024-06-19 18:31:01 +0200
committerLizzy Fleckenstein <lizzy@vlhl.dev>2024-06-19 18:50:31 +0200
commit6490c179e7f789a9efb876fa0bdfc195dc374dc5 (patch)
treebf59dba04da15e40f6489650aef589a04cafd7a3 /src/client.c
parent49948b4cc0f73d02a8932c525690a35e8efb6ac5 (diff)
handle signals
Signed-off-by: Lizzy Fleckenstein <lizzy@vlhl.dev>
Diffstat (limited to 'src/client.c')
-rw-r--r--src/client.c8
1 files changed, 7 insertions, 1 deletions
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