diff options
author | Kenny Levinsen <kl@kl.wtf> | 2020-08-04 01:43:55 +0200 |
---|---|---|
committer | Kenny Levinsen <kl@kl.wtf> | 2020-08-04 01:43:55 +0200 |
commit | 55cbe043e23dc2e8ed8b398034cd16b0156bba70 (patch) | |
tree | dd3aee542e9e085d3b859dcc78c67c2bd3f5c688 /seatd | |
parent | db36f0dfe863e2fe20bcb4e8ef4ba06579ab2e53 (diff) |
server: Gracefully shut down on error
Diffstat (limited to 'seatd')
-rw-r--r-- | seatd/server.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/seatd/server.c b/seatd/server.c index 354d6a5..799fda0 100644 --- a/seatd/server.c +++ b/seatd/server.c @@ -120,9 +120,10 @@ static int set_nonblock(int fd) { static int server_handle_connection(int fd, uint32_t mask, void *data) { struct server *server = data; if (mask & (EVENT_ERROR | EVENT_HANGUP)) { - close(fd); + shutdown(fd, SHUT_RDWR); + server->running = false; log_errorf("server socket recieved an error: %s", strerror(errno)); - exit(1); + return -1; } if (mask & EVENT_READABLE) { |