From 93b81bf41db2424cbcc3f7c9a96268737071eedf Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Mon, 26 Dec 2016 15:04:13 +0100 Subject: Use sigaction for better SIGCHLD handling on linux --- main.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index 52d10bd..0b4886b 100644 --- a/main.c +++ b/main.c @@ -1,3 +1,4 @@ +#define _GNU_SOURCE // sigaction #include #include #include @@ -142,7 +143,14 @@ int main(int argc,char **argv){ return 1; } - signal(SIGCHLD,signal_handler); + struct sigaction sa; + sa.sa_handler=signal_handler; + sigemptyset(&sa.sa_mask); + sa.sa_flags=SA_RESTART; + if(sigaction(SIGCHLD,&sa,NULL)<0){ + perror("sigaction"); + return 1; + } printf("Listening on port %d\n",PORT); -- cgit v1.2.3-70-g09d2