mirror of
https://github.com/moonlight-stream/moonlight-common-c.git
synced 2025-08-18 09:25:49 +00:00
Ignore SIGPIPE on POSIX platforms to fix the crash on connection closure in Limelight-iOS
This commit is contained in:
parent
df9ba620e8
commit
25faaa9e6b
@ -68,6 +68,17 @@ int initializePlatformSockets(void) {
|
|||||||
#if defined(LC_WINDOWS) || defined(LC_WINDOWS_PHONE)
|
#if defined(LC_WINDOWS) || defined(LC_WINDOWS_PHONE)
|
||||||
WSADATA data;
|
WSADATA data;
|
||||||
return WSAStartup(MAKEWORD(2, 0), &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
|
#else
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
|
@ -18,6 +18,8 @@ typedef int SOCK_RET;
|
|||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <signal.h>
|
||||||
|
|
||||||
#define LastSocketError() errno
|
#define LastSocketError() errno
|
||||||
#define SetLastSocketError(x) errno = x
|
#define SetLastSocketError(x) errno = x
|
||||||
#define INVALID_SOCKET -1
|
#define INVALID_SOCKET -1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user