From 6ce76758206cbd22a02a163013a026d67aff398a Mon Sep 17 00:00:00 2001 From: James Laird Date: Mon, 9 Jan 2012 10:18:17 +1100 Subject: [PATCH] Reap child processes in shairport.c --- shairport.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/shairport.c b/shairport.c index 0a0178ae..ad4d4894 100644 --- a/shairport.c +++ b/shairport.c @@ -25,6 +25,7 @@ */ #include +#include #include "socketlib.h" #include "shairport.h" #include "hairtunes.h" @@ -51,8 +52,23 @@ extern int buffer_start_fill; #define HEADER_LOG_LEVEL LOG_DEBUG #define AVAHI_LOG_LEVEL LOG_DEBUG +void handle_sigchld(int signo) { + int status; + waitpid(-1, &status, WNOHANG); +} + int main(int argc, char **argv) { + // unfortunately we can't just IGN on non-SysV systems + struct sigaction sa; + sa.sa_handler = handle_sigchld; + sa.sa_flags = 0; + sigemptyset(&sa.sa_mask); + if (sigaction(SIGCHLD, &sa, NULL) < 0) { + perror("sigaction"); + return 1; + } + char tHWID[HWID_SIZE] = {0,51,52,53,54,55}; char tHWID_Hex[HWID_SIZE * 2 + 1]; memset(tHWID_Hex, 0, sizeof(tHWID_Hex));