Use signalfd to handle SIGINT and SIGTERM shutdown.

This commit is contained in:
Ian Gulliver
2016-03-08 22:26:04 -08:00
parent ba13ebbe5c
commit e885723c59
3 changed files with 24 additions and 25 deletions

View File

@@ -2,6 +2,7 @@
#include <fcntl.h>
#include <netdb.h>
#include <pthread.h>
#include <signal.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
@@ -28,6 +29,11 @@ static int asyncaddrinfo_write_fd;
static void *asyncaddrinfo_main(void *arg) {
int fd = (int) (intptr_t) arg;
sigset_t sigmask;
assert(!sigfillset(&sigmask));
assert(!pthread_sigmask(SIG_BLOCK, &sigmask, NULL));
struct asyncaddrinfo_resolution *res;
ssize_t len;
while ((len = recv(fd, &res, sizeof(res), 0)) == sizeof(res)) {