diff options
author | Tom Smeding <tom.smeding@gmail.com> | 2016-12-26 15:04:13 +0100 |
---|---|---|
committer | Tom Smeding <tom.smeding@gmail.com> | 2016-12-26 15:04:13 +0100 |
commit | 93b81bf41db2424cbcc3f7c9a96268737071eedf (patch) | |
tree | 3cacae8194ade3adad1f87ba4300c34871028360 | |
parent | 2f19f2e85746eca309ae5e355e1ff860c62ec11d (diff) |
Use sigaction for better SIGCHLD handling on linux
-rw-r--r-- | main.c | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -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); |