From 25faaa9e6bd04ed35bb94d66c38f6229c5a1c30a Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Mon, 20 Oct 2014 23:27:41 -0400 Subject: [PATCH] Ignore SIGPIPE on POSIX platforms to fix the crash on connection closure in Limelight-iOS --- limelight-common/PlatformSockets.c | 11 +++++++++++ limelight-common/PlatformSockets.h | 2 ++ 2 files changed, 13 insertions(+) diff --git a/limelight-common/PlatformSockets.c b/limelight-common/PlatformSockets.c index d754c12..55be75c 100644 --- a/limelight-common/PlatformSockets.c +++ b/limelight-common/PlatformSockets.c @@ -68,6 +68,17 @@ int initializePlatformSockets(void) { #if defined(LC_WINDOWS) || defined(LC_WINDOWS_PHONE) WSADATA data; return WSAStartup(MAKEWORD(2, 0), &data); +#elif defined(LC_POSIX) + // Disable SIGPIPE signals to avoid us getting + // killed when a socket gets an EPIPE error + struct sigaction sa; + sa.sa_handler = SIG_IGN; + sa.sa_flags = 0; + if (sigaction(SIGPIPE, &sa, 0) == -1) { + perror("sigaction"); + return -1; + } + return 0; #else return 0; #endif diff --git a/limelight-common/PlatformSockets.h b/limelight-common/PlatformSockets.h index 40dbd5c..f101872 100644 --- a/limelight-common/PlatformSockets.h +++ b/limelight-common/PlatformSockets.h @@ -18,6 +18,8 @@ typedef int SOCK_RET; #include #include #include +#include + #define LastSocketError() errno #define SetLastSocketError(x) errno = x #define INVALID_SOCKET -1