network: prevent SIGPIPE on OSX
authorwm4 <nfxjfg@googlemail.com>
Sat, 30 May 2015 18:50:43 +0000 (20:50 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Sat, 30 May 2015 20:29:19 +0000 (22:29 +0200)
OSX does not know MSG_NOSIGNAL, and provides its own non-standard
mechanism instead. I guess Apple hates standards.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavformat/network.c

index 8cc5aad..47ade8c 100644 (file)
@@ -180,6 +180,10 @@ int ff_socket(int af, int type, int proto)
         }
 #endif
     }
+#ifdef SO_NOSIGPIPE
+    if (fd != -1)
+        setsockopt(fd, SOL_SOCKET, SO_NOSIGPIPE, &(int){1}, sizeof(int));
+#endif
     return fd;
 }