summaryrefslogtreecommitdiff
path: root/src/server.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/server.c')
-rw-r--r--src/server.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/server.c b/src/server.c
index 621acae..5355620 100644
--- a/src/server.c
+++ b/src/server.c
@@ -19,6 +19,7 @@
#include "net.h"
#include "str.h"
#include "ser.h"
+#include "sig.h"
typedef enum {
MAP_VALLEY,
@@ -318,6 +319,8 @@ bool handle_pkt(str pkt, player *p, game *g)
int main()
{
+ signal_setup();
+
game g = {0};
g.accept_fd = -1;
@@ -364,11 +367,14 @@ int main()
if (poll(fds, g.players.len + 1, -1) < 0) {
switch (errno) {
- case EINTR: continue;
+ case EINTR: break;
default: perror("poll"); continue;
}
}
+ if (signal_stop)
+ game_exit(&g, EXIT_SUCCESS);
+
for (size_t i = 0; i < g.players.len; i++) {
player *p = &g.players.data[i];