UI: Block SIGPIPE in all threads

This can happen when trying to write to a closed socket (in the case
of an RTMP server closing the connection).
This commit is contained in:
Tristan Matthews 2019-05-09 12:07:40 -04:00 committed by jp9000
parent 94c881b891
commit 4bb002c4d3

View file

@ -50,6 +50,7 @@
#include <windows.h>
#else
#include <signal.h>
#include <pthread.h>
#endif
#include <iostream>
@ -2245,6 +2246,18 @@ int main(int argc, char *argv[])
sig_handler.sa_flags = 0;
sigaction(SIGINT, &sig_handler, NULL);
/* Block SIGPIPE in all threads, this can happen if a thread calls write on
a closed pipe. */
sigset_t sigpipe_mask;
sigemptyset(&sigpipe_mask);
sigaddset(&sigpipe_mask, SIGPIPE);
sigset_t saved_mask;
if (pthread_sigmask(SIG_BLOCK, &sigpipe_mask, &saved_mask) == -1) {
perror("pthread_sigmask");
exit(1);
}
#endif
#ifdef _WIN32