summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Smeding <tom.smeding@gmail.com>2016-12-26 15:04:13 +0100
committerTom Smeding <tom.smeding@gmail.com>2016-12-26 15:04:13 +0100
commit93b81bf41db2424cbcc3f7c9a96268737071eedf (patch)
tree3cacae8194ade3adad1f87ba4300c34871028360
parent2f19f2e85746eca309ae5e355e1ff860c62ec11d (diff)
Use sigaction for better SIGCHLD handling on linux
-rw-r--r--main.c10
1 files changed, 9 insertions, 1 deletions
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 <stdio.h>
#include <stdbool.h>
#include <string.h>
@@ -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);